anhpnguyen / tc359_rails_final

0 stars 0 forks source link

Phusion Passenger #1

Open anhpnguyen opened 9 years ago

anhpnguyen commented 9 years ago

@chrisvfritz Hi Chris! Looks like I have successfully used Phusion Passenger. I understand that it allows our web apps to run faster, but I want to hear what you think about it too. Can you give me some input?

chrisvfritz commented 9 years ago

:+1: Phusion Passenger is my current preferred web server for Rails applications. This article has a great explanation for how the latest version of Phusion Passenger manages to be so fast.

Like with many other web servers, you can also serve multiple instances of your app simultaneously - almost like having several servers to share the load. Your Procfile defines the maximum number of threads to serve with --max-pool-size. A Rails app will often take between 100MB and 150MB of memory. We have access to 500MB of memory on a free Heroku node. So we can take our max memory we want to dedicate to our app (500) and divide it by the max memory our app tends to take up (150) and we get 3.333. Round down and you've got room for 3 threads of your app to run side-by-side. That's we we set --max-pool-size 3. :smiley:

Let me know if that helps! I'm by no means a web server expert, but I'd be happy to answer any other questions as best I can.

chrisvfritz commented 9 years ago

I actually have one other tip that's often useful when testing out web servers. The Apache Benchmark tool comes with OS X (I'm pretty sure) and allows you to test response times for your website under certain loads.

For example, if I want to try visiting Codekwondo 100 times (-n 100), with 3 visits at a time (-c 3), I can run this line in the terminal:

ab -n 100 -c 3 https://codekwondo.herokuapp.com/

Which will give you something like this:

Percentage of the requests served within a certain time (ms)
  50%    357
  66%    373
  75%    382
  80%    387
  90%    416
  95%    441
  98%    510
  99%    576
 100%    576 (longest request)

Very useful info when comparing the performance of different web servers with a specific app.

anhpnguyen commented 9 years ago

Thanks Chris!! I'd really appreciate that you're taking your time. I will continue to work on writing all my HTML views in Slim.

On Thu, Apr 16, 2015 at 3:19 PM, Chris Fritz notifications@github.com wrote:

I actually have one other tip that's often useful when testing out web servers. The Apache Benchmark tool comes with OS X (I'm pretty sure) and allows you to test response times for your website under certain loads.

For example, if I want to try visiting Codekwondo 100 times (-n 100), with 3 visits at a time (-c 3), I can run this line in the terminal:

ab -n 100 -c 3 https://codekwondo.herokuapp.com/

Which will give you something like this:

Percentage of the requests served within a certain time (ms) 50% 357 66% 373 75% 382 80% 387 90% 416 95% 441 98% 510 99% 576 100% 576 (longest request)

Very useful info when comparing the performance of different web servers with a specific app.

— Reply to this email directly or view it on GitHub https://github.com/anhpnguyen/tc359_rails_final/issues/1#issuecomment-93819456 .

chrisvfritz commented 9 years ago

:smiley: Not a problem.