16

我有 3 台 Web 服务器需要优化。我目前每天只有 2000 多位独立访问者,我想提高我的服务器的性能,以确保什么时候获得更多流量,一切都会顺利进行。

我读过(在一些博客上)APC、memcache 和 Varnish 是优化网站性能的最佳工具。

如果我有静态(例如条款和条件页面)和动态内容(用户设置页面),同时使用所有三个是否很好?

非常感谢,J。

4

4 回答 4

20

每天的访客数量并不意味着什么,它是杀死你的高峰。如果每天所有 2000 次点击都在一分钟内出现,那么您可能会遇到问题,但如果它们在一天中均匀分布,即使在高度计算的 web 应用程序上,您也不应该有太多问题。

无论如何,如果您希望扩展,Varnish 可能会为您提供最大的帮助,因为它允许您设置尽可能高效的客户端缓存,因为它限制了与服务器的交互量。

APC 和 memcache 是 Varnish 无法提供结果时的后备方案。APC 将加速您的 PHP。memcache 允许你做一些事情,比如从你的数据库中为用户抓取一些复杂的数据,然后在接下来的 x 分钟/天/周内为用户提供该数据的缓存版本。如果您有任何耗时的查询,这可能会产生巨大的影响。

编辑:我一直想尝试Cloudflare CDN一段时间,在这样做之后我不得不回来推荐它。他们有一个免费帐户(我正在使用),只要您知道如何更改 DNS 记录,设置它就非常容易。在所有提到的技术中,这可能是您加快网站速度的最佳第一步。只是为了让您知道我没有 Cloudflare 或类似的股票,但我正在认真考虑。:)

于 2011-09-09T17:47:22.303 回答
8

所有 3 的组合很有用,但将它们用于不同的事情: Varnish:可以缓存静态内容并以极快的速度交付它(减少 apache 的负载) APC:存储 php 操作码,以便由 php 处理的调用更快 Memcache:用作应用程序的临时数据存储,以减少对数据库的调用(数据库通常是瓶颈)

如果您有时间,请按以下顺序使用所有 3 个:APC(快速启动和运行) Varnish(需要一些配置,但对于静态页面非常值得)Memcache(代码更改以进行使用它,所以显然需要更多的思考和时间)

于 2011-09-15T10:41:32.257 回答
1

APC 将帮助处理任何 PHP 页面,而 Memcached 只有在您明确使用它时才会有所帮助。我从来没有使用过 Varnish,所以我对此一无所知。

编辑:Varnish 可以缓存静态和动态生成的文件以提高性能。

于 2011-09-08T20:03:38.847 回答
0

All three can help a lot - but 2000 visitors a day really isn't that much.

Because APC is so easy to put into a LAMP system, I'd put it in there (and have for my own website, and that might get 5 visitors a day), but not bother about the others unless you had some kind of problem, that required the additional effor, such as far larger numbers of visitors, or hundreds of gigabytes of image/video downloads.

Memcache would also require some active use beyond basic configuration as well (or at least using a plugin that used it appropriately, for Wordpress or some other off-the-shelf software) - just installing the software does nothing at all.

于 2011-09-08T20:14:36.780 回答