扩展 PHP 网站

发布于 2024-09-25 08:38:43 字数 175 浏览 3 评论 0原文

是否有标准解决方案来扩展在 PHP + Apache Web 服务器上运行的网站? 到目前为止,我每天收到的流量约为 100,000 个请求。 6 个月后,我预计它会增长到每天 200,000 个请求。我想到的第一个解决方案是使用 mod_php 部署更多 Apache Web 服务器,但似乎有些问题。

有什么想法吗?

Is there a standard solution to scale up a website which runs on PHP + Apache web server ?
As in I get a traffic of about 100,000 requests/day as of now. 6 months down the line I expect it to grow to 200,000 requests/day. The first cut solution which comes to my mind is deploying more Apache web servers with mod_php, but something seems so wrong about it.

Any ideas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

星星的轨迹 2024-10-02 08:38:43

在添加新服务器之前,请先尝试这两个选项。它们可能允许您坚持使用一台服务器,但您的结果可能会有所不同。

为了在遇到许多并发用户时加快网站速度,请考虑安装 APC PECL 扩展 (http://us2.php.net/manual/en/book.apc.php)。 APC 将允许您缓存脚本的编译版本,从而保存每次执行脚本时 PHP 解释器运行的步骤。

另外,如果数据库服务器负载过重,请考虑安装 memcached 并在一定时间段内缓存数据库结果(如果可能的话) (http://us2.php.net/manual/en/book.memcache.php) 。

最后,如果您决定购买单独的服务器,请考虑购买专用的 SQL 框。当然,这是假设您的应用程序是一个数据库密集型应用程序,就像现在的 Web 应用程序一样。将 SQL 分离到一个单独的盒子中可以使其利用该盒子上的所有资源,并具有更多的缓存和处理能力。这可能是一条出路。

Try these two options first before adding new servers. They may allow you to stick with one server, but your results may vary.

For speeding the site up when you are hit with many concurrent users, look into installing the APC PECL extension (http://us2.php.net/manual/en/book.apc.php). APC will allow you to cache the compiled version of your scripts, saving the step of the PHP interpreter running each time a script is executed.

Also, if you are experiencing heavy load on the database server, look into installing memcached and caching database results for a certain time period, if possible (http://us2.php.net/manual/en/book.memcache.php).

Finally, if you do decide to get a separate server, look into possibly getting a dedicated SQL box. This, of course, assumes that your application is a database heavy application, as web apps are these days. Segregating SQL into a separate box allows it to take advantage of all of the resources on that box, with more cache and processing power. It could be the way to go.

命硬 2024-10-02 08:38:43

我没有任何扩展大型网站的经验,但我认为在这种情况下您不需要扩展到不同的服务器。我有一个浏览器游戏,每天有 40.000-60.000 个请求,一些 cronjobs 每 5 分钟做很多事情,还有一个小服务器上的 teampeak-server(40 美元/月),到目前为止还没有任何性能问题。

i don't have any experience with scaling realy large websites, but i don't think you'll need so scale to different servers in this case. i have a browsergame with 40.000-60.000 requests per day, some cronjobs doing a lot of stuff every 5 minutes and a teamspeak-server on a small server (40 $ / month) and havn't got any performance problems till now.

友欢 2024-10-02 08:38:43

每天 20.000 个请求只是每五秒一次,听起来一个盒子应该能够处理这个问题吧?如果不是,我会首先查看代码中的瓶颈。冗余数据库调用?双循环数据库调用而不是简单连接?你缓存什么东西吗?

此后如何扩展完全取决于您的应用程序、如何/在哪里保存会话状态等等,一般建议的适用性有限。

20.000 requests / day is only one every fifth second, sounds like one box should be able to deal with that just fine? If not I'd first have a look at bottlenecks in your code. Redundant database calls? Double-looping database calls rather than simple joins? Are you caching anything?

How to scale after this is totally dependent on your application, how/where do you keep session state and so forth, general advice has limited applicability.

旧情别恋 2024-10-02 08:38:43

如果你喜欢它那么你应该在上面放置一个缓存

if you like it then you should have put a cache on it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文