Asked  6 Months ago    Answers:  5   Viewed   71 times

I want to use Node because it's swift, uses the same language I am using on the client side, and it's non-blocking by definition. But the guy who I hired to write the program for file handling (saving, editing, renaming, downloading, uploading files, etc.), he wants to use apache. So, I must:

  1. Convince him to use Node (he's giving up little ground on that)

  2. Figure out how to upload, download, rename, save, etc. files in node or

  3. I must install apache and node on the same server.

Which is the most favorable situation, and how do I implement that?

 Answers

43

Great question!

There are many websites and free web apps implemented in PHP that run on Apache, lots of people use it so you can mash up something pretty easy and besides, its a no-brainer way of serving static content. Node is fast, powerful, elegant, and a sexy tool with the raw power of V8 and a flat stack with no in-built dependencies.

I also want the ease/flexibility of Apache and yet the grunt and elegance of Node.JS, why can't I have both?

Fortunately with the ProxyPass directive in the Apache httpd.conf its not too hard to pipe all requests on a particular URL to your Node.JS application.

ProxyPass /node http://localhost:8000

Also, make sure the following lines are NOT commented out so you get the right proxy and submodule to reroute http requests:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Then run your Node app on port 8000!

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Apache!n');
}).listen(8000, '127.0.0.1');

Then you can access all Node.JS logic using the /node/ path on your url, the rest of the website can be left to Apache to host your existing PHP pages:

enter image description here

Now the only thing left is convincing your hosting company let your run with this configuration!!!

Tuesday, June 1, 2021
 
bancer
answered 6 Months ago
82

It means a single test with a total of 100 requests, keeping 20 requests open at all times. I think the misconception you have is that requests all take the same amount of time, which is virtually never the case. Instead of issuing requests in batches of 20, ab simply starts with 20 requests and issues a new one each time an existing request finishes.

For example, testing with ab -n 10 -c 3 would start with3 concurrent requests:

[1, 2, 3]

Let's say #2 finishes first, ab replaces it with a fourth:

[1, 4, 3]

... then #1 may finish, replaced by a fifth:

[5, 4, 3]

... Then #3 finishes:

[5, 4, 6]

... and so on, until a total of 10 requests have been made. (As requests 8, 9, and 10 complete the concurrency tapers off to 0 of course.)

Make sense?

As to your question about why you see results with more failures than total requests... I don't know the answer to that. I can't say I've seen that. Can you post links or test cases that show this?

Update: In looking at the source, ab tracks four types of errors which are detailed below the "Failed requests: ..." line:

  • Connect - (err_conn in source) Incremented when ab fails to set up the HTTP connection
  • Receive - (err_recv in source) Incremented when ab fails a read of the connection fails
  • Length - (err_length in source) Incremented when the response length is different from the length of the first good response received.
  • Exceptions - (err_except in source) Incremented when ab sees an error while polling the connection socket (e.g. the connection is killed by the server?)

The logic around when these occur and how they are counted (and how the total bad count is tracked) is, of necessity, a bit complex. It looks like the current version of ab should only count a failure once per request, but perhaps the author of that article was using a prior version that was somehow counting more than one? That's my best guess.

If you're able to reproduce the behavior, definitely file a bug.

Wednesday, March 31, 2021
 
nhunston
answered 9 Months ago
33

There is little risk with running mod_php and mod_rails on the same Apache server.

In fact, Passenger won't affect Apache if it goes down so it is actually a good choice to use with Apache and mod_php. From the Passenger Architectural Overview:

It should be noted that the Ruby on Rails application does not run in the same address space as Apache. This differentiates Passenger from other application-server-inside-web-server software such as mod_php, mod_perl and mod_ruby. If the Rails application crashes or leak memory, it will have no effect on Apache. In fact, stability is one of our highest goals. Passenger is carefully designed and implemented so that Apache shouldn't crash because of Passenger.

Saturday, May 29, 2021
 
Dev
answered 7 Months ago
Dev
61

Seems like all I was missing was a

<base href="/node/">

tag (didn't even know about it, and Yeoman created it as )

I still have a problem though :

Socket.io ... I don't really get my own problem here : it's in node_modules (wich is normal since I need it in my server and my client), but trying to include it as I was doing so before using base href fails. I don't even get how it did work before : (index.html : ) <script src="socket.io-client/socket.io.js"></script> This doesn't seem right knowing my project folder is like this :

[PROJECT ROOT]

-client

--index.html

-node_modules

--socket.io-client

---socket.io.js

Monday, November 22, 2021
 
James
answered 1 Week ago
71

Absolutely. Just make sure that they have read and write access to that shared folder.

Then set up a symlink from each of the theme folders. You do this with ln -s <origin> <new>

If you can't use symbolic links, you can then set up a rewrite-rule, which redirects all requests from /wp-content/themes to like /var/www/shared/themes.

If you want, I can provide an example.

Wednesday, November 24, 2021
 
nika
answered 6 Days ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share