Open ghost opened 8 years ago
Running nodejs on port 80 requires root which can be a security concern. Additionally handling the complexity of SSL may be something to hand off to a reverse proxy.
+1 for performance comparison to nginx. Please Please!
Redbird is similar to Nginx in its purpose, though Nginx has a much fuller feature set and is much faster (it's written in C, what do you expect the benchmark to show?).
One thing I like about Redbird is that routes can be modified on the fly with no downtime. Nginx servers must be restarted to modify routes. It's also in NodeJS, and I know NodeJS well and Nginx config language not very well, so for me it's highly configurable.
My specific usecase is that I have a lot of different websites running on a single EC2 server. Redbird is very very lightweight (t2.micro doesn't have much space, and I guess nginx would be alright, but shrug), and I can do cool things with it in NodeJS.
I think that for the sake of comparison it would be nice to provide some benchmarks. At least we would be able to see how much performance we are loosing by not using nginx and helping the user to understand if redbird is a suitable alternative or not. I do not expect it to be terribly un-performance though, since at the end it is using nodejs libuv which is supposed to be quite efficient and becomes more efficient in every release. Then you have the v8 overhead which of course will introduce latencies that are more difficult to optimize. I will try to make some benchmarks when I have some spare time.
@manast Thanks!
I love node so proxying with it would be bomb! But it would help me make the switch more comfortable if I knew what loses I would be taking.
@manast thanks
I also wanted to know what performance hit I'd take when using redbird, and did some benchmarks myself using httperf.
First I've started a simple hello world server, and clustered it using pm2 start ./test.js -i max
to use all cores.
Then I've benchmarked it using httperf --server myserver.com --port myport --num-conn 1000
and it was able to do around 2800 requests per second.
Then I've done the same through nginx, and it was able to process around 1800 req/s. Then I've done the same through redbird, and it was only able to process around 800 req/s.
So.. the performance hit is pretty big compared to nginx. But I'm no expert in bencharking, so take those results not for serious. Other benchmarks might result in something completely different.
Anyways, I won't use redbird for anything that is under heavy load. But for my private stuff, it's really cool and the easy configuration is absolutely worth it.
@VanCoding run the same test but setting the global http agent to keep alive. There is more info regarding performance in this thread: https://github.com/nodejitsu/node-http-proxy/issues/1058 Redbird should perform almost the same as http-proxy-
@manast I'm not sure if I understood that correctly. I've removed the comments here: https://github.com/OptimalBits/redbird/blob/master/lib/proxy.js#L81
This improved the requests per second to 1200 from 800.
and are you using cluster? since nginx is threaded in order to compare in the same terms you need to enable cluster.
oh well, no I didn't. I thought it was on by default.
Turning it on makes it only slower, though. I've tried with redbirds cluster
option and also tried running the proxy with pm2's -i max
, but in both cases, it had only half the requests per second as before (~600). Running a single process thoug gave me 1200 req/s again.
But reading the readme, I've found out I can also disable loggin. This brought me another 300 req/s. So the distance isn't that big to nginx anymore.
But it's really strange that clustering doesn't speed it up. The hello world server is clustered from the beginning and it gives me 4x the requests per second compared to it running in a single process.
Maybe something's wrong with my VM, I don't know. I really wouldn't give much about my tests... I'm looking forward to your benchmarks.
@VanCoding I think you should use less cores. The benchmark and the os requires at least a single core I think. I am not sure about what pm2 does by max cores, so maybe it uses n-1
by default. Try with the exact numbers, maybe it changes the speeds.
I think the performance is not that bad. At least we can start to identify bottlenecks and make the lib faster.
Running nodejs on port 80 requires root which can be a security concern. Additionally handling the complexity of SSL may be something to hand off to a reverse proxy.
Or it simply requires configuring the OS properly which still requires the dev to have root but node doesn't need to run as root.
Would be nice to have a graph, but thanks @VanCoding for the results, those would do for me for now.
@manast when you get the chance, would love to see how v1.0.2 compares to NGINX without logging turned on.
Are there any benchmarks which compare redbird with apache and nginx for example by serving static files. People use nginx with express because it serves static files much faster. According to them nginx prevents DDOS attacks as well, and increases security. Ofc. I never saw any concrete examples. I think they just use it because everyone else do so.
off: In my case I cannot find a real purpose to use a reverse proxy with nodejs. I have a home server with some nodejs services. Some of them run express and have HTTP interface. These are mostly for personal usage on the local network, but I think I'll add a dyndns and publish a few, for example my blog. It does not really need performance by static files, etc. Why do I need a reverse proxy to do this? Wouldn't express + fail2ban + port forwarding on the router be enough?