HTTP在AJAX站点上的Alive Alive好处 [英] HTTP Keep Alive benefits on AJAX site

查看:60
本文介绍了HTTP在AJAX站点上的Alive Alive好处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 http:上有一个相当繁重的AJAX网站.//www.beckworthemporium.com/index.php?option=com_rsappt_pro2&view=booking_screen_gad&Itemid=58

当前,每个页面请求都使用5/6 AJAX请求来返回页面的各个部分,并且这些过程都是mySQL密集型的.直到圣诞节,我们的流量都会缓慢增加.我们会发现使用Keep alive有什么好处吗?

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?

推荐答案

您在谈论多少流量?如果计划使用Keep-alive,则可能要确保有足够的内存并将Keep Alive超时降低到最低,否则,如果最终获得大量流量,可能会伤害您.流量过大的网站通常会保持活动状态.

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.

也请看一看,并阅读现代的http保持活跃状态​​

我在您的页面上运行了一个报告 http://www.webpagetest.org/result/121008_TX_KB9/

I ran a report on your page at http://www.webpagetest.org/result/121008_TX_KB9/

对于您的AJAX调用,无论您是否使用保持活动状态,我都将对其进行改进.我会缓存响应.例如,在运行mysql查询并生成输出后,将其缓存到磁盘数小时(如果可能的话,甚至更长),然后在后续调用中从磁盘中提取数据(如果尚未过期).这样可以节省一堆并总体上加快速度.

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.

此外,如果您担心速度,我会在很多图像资源中使用图像精灵.我注意到您的某些图像是占位符,并且是100%透明的,请考虑仅将CSS用于这些图像.这将大大减少您的总体要求.

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.

我还将启用mod_expires并添加一些Expires标头.对于使用这些以及更多良好实践功能的htaccess文件示例,请查看: https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess

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

编辑

Jeepstone,我建议您不要启用保持活动状态,并可能使用CDN和并行化您的资源.您可能还需要查看数据库配置.例如,MySQL的最大连接数较低,您可能希望优化慢速查询,连接超时并确保不使用任何持久性连接.

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.

如果您真的很担心Web堆栈的状态,则可以立即对其进行测试,而不是在有更多真正的客户来敲门时找出问题的根源.我说的是压力/负载测试.

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.

这篇关于HTTP在AJAX站点上的Alive Alive好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆