简体   繁体   English

PHP Apache服务器中的最大连接限制

[英]Max connection limit in php apache server

I have 32 GB ubuntu server where my site is hosted. 我的网站托管在32 GB的ubuntu服务器上。 I have installed the XAMPP and running my site. 我已经安装了XAMPP并正在运行我的网站。 So here my question is what is the limit of maximum concurrent connections apache will handle and how I can check that? 所以在这里我的问题是,apache将处理的最大并发连接数限制是多少?我该如何检查? At which extent I can increase it and how? 我可以在多大程度上增加它?如何增加呢? My server must have 5000 concurrent users at a time So for that I have to configure it. 我的服务器一次必须有5000个并发用户,因此我必须对其进行配置。

Generally the formula is : 通常的公式是:

(Total available memory - Memory needed by operating system) / memory each PHP process needs.

Honestly it's a bit hard to predict sometimes, so it might be worth doing some experimentation. 老实说,有时候很难预测,因此值得进行一些实验。 The goal is that you never use more memory that available, so your operating system never swaps. 目标是您永远不会使用更多的可用内存,因此您的操作系统永远不会交换。

However, you can also turn it around. 但是,您也可以将其转过来。 5000 concurrent requests is frankly a lot, so I'm going by your 5000 concurrent users. 坦率地说,有5000个并发请求,因此,我要介绍5000个并发用户。

Say if 5000 users are actively using your application at a given time, and maybe they do on average each 1 request every 30 seconds or so. 假设有5000个用户在给定时间正在积极使用您的应用程序,也许他们平均每30秒左右发出1个请求。 And say that the average PHP script takes 100ms to execute. 并说平均PHP脚本执行需要100毫秒。

That's about 166 requests per second made by your users. 用户每秒大约有166个请求。 Given that it takes 100ms to fulfill a request, it means you need about 17 connections to serve all that up. 鉴于完成一个请求需要100毫秒,这意味着您需要大约17个连接来提供所有服务。 Which is easy for any old server. 对于任何旧服务器而言,这都很容易。

Anyway, the key to all these types of dilemmas is to: 无论如何,所有这些困境的关键在于:

  • Make an educated guess 进行有根据的猜测
  • Measure 测量
  • Make a better guess 做出更好的猜测
  • Repeat 重复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM