问题
We have a reasonably heavy AJAX site at http://www.beckworthemporium.com/index.php?option=com_rsappt_pro2&view=booking_screen_gad&Itemid=58
Currently each page request uses 5/6 AJAX requests to return the various pieces of the page and are fairly mySQL intensive. We'll be due a slow increase in traffic up until Christmas. Would we see any benefit of using keep alive?
回答1:
How much traffic are you talking about? If you plan to use Keep-alive then you might want to ensure you have enough memory and lower the keep alive timeout to the lowest possible otherwise if you end up getting a lot of traffic it could hurt you. Sites with excessive traffic usually have keep alive disabled.
Also take a look and read http keep-alive in the modern age
I ran a report on your page at http://www.webpagetest.org/result/121008_TX_KB9/
As for your AJAX calls, I would improve those whether you use keep-alive or not. I would cache the responses. For example after you run your mysql queries and generate your output, cache it to disk for a few hours (or longer if possible) and then on subsequent calls pull the data from disk if it has not expired. This will save a bunch and speed up things overall.
Also if you're concerned about speed, I would use image sprites for a lot of your image resources. I notice some of your images are placeholders and are 100% transparent, consider using css only for those. This will reduce your overall requests dramatically.
I would also enable mod_expires and add some Expires headers. For an example htaccess file using these and more good practice features look at: https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess
EDIT
Jeepstone, I would recommend you don't enable keep-alive and maybe use a CDN and Parallelize your resources. You may also want to look at your database config. For example MySQL has low max connections and you might want to optimize slow queries, connection timeouts and ensure that you do not use any persistent connections.
Also if you're really concerned about the state of your web stack you can test it right now instead of finding out the problems down the line when there are a lot more real customers knocking. I'm talking about stress/load testing.
- Check out Best way to stress test a website
- and http://blazemeter.com/
- and maybe http://loadimpact.com/
回答2:
There are two big issues on large sites: concurrent connections and latency. Looking at your Christmas numbers, I don't think your site is large. Therefore I would not see a big benefit from using Keep-Alive. Enabling Keep-Alive might increase the number of idle connections which would not help.
I would go the route of load testing your website, see what is the biggest bottleneck and fix it. Iterate by finding the biggest bottleneck and improve. You might find in your instance that the database is the main culprit. There are free load testing tools out there, or semi-free: VS Test Suite offers free for MSDN subscribers up to 250 virtual real concurrent users, which is more than you need.
来源:https://stackoverflow.com/questions/12568376/http-keep-alive-benefits-on-ajax-site