nginx - How to set web service parameters based on server configuration?
淡淡烟草味
淡淡烟草味 2017-05-16 17:02:45
0
3
551

I have been messing around with server-related things recently and encountered some problems. I would like to ask everyone for help.
Current website access status: PV: 15W+, IP: 2W+
server configuration:
CPU: 4 * Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz
Memory: 4G
Bandwidth: 6M
Hard drive: 2 * 100G HDD


This server used to use wdcp panel, php5.2 + mysql 5.1. The CPU and load during peak periods have been very stable. Later, after the site was hacked, I took over the processing. After reinstalling the system, it was also built with one click. Environment (package on blog.linuxeye.com), built Lanmp environment, after starting the service, use another server ab test (ab -c 100 -n 500), the CPU is immediately full, and the load is also soaring. The program is WordPress, although it can withstand the current peak period, the CPU is often around 98%, and the access speed is not as fast as before;
By checking the concurrency netstat -an | grep ESTABLISHED | wc -l, it is obvious that you have to wait about 3 seconds when accessing at around 600 during the peak period, and the load is also very high.

What I want to know about this is:

  1. With this server configuration, is this amount of visits considered the limit? To what extent can it be achieved?
  2. Apache (2.4) works in prefork mode. Will a process be created when a user accesses it?
  3. The MaxConnectionsPerChild parameter in the prefork configuration in Apache is the maximum number of connections for each process. What does this number of connections refer to? For example, when accessing a page, there will be js, css, and img requests at the same time, which refers to these keepAlive Number of connections during the period?
  4. How to determine and set the configuration parameters of apache or nginx based on the current server configuration? How is the resource usage calculated?

Please give me some guidance from experienced seniors, thank you!

淡淡烟草味
淡淡烟草味

reply all(3)
曾经蜡笔没有小新

See what is occupying the CPU, is it waiting for IO.

If you already have Nginx, just use Nginx + PHP-FPM. There is no need to use Apache (unless you have other things that require Apache). Try to use PHP-FPM instead of mod_php, and set PHP-FPM appropriately according to the memory. The maximum number of processes (one process requires about 20-40M memory).

为情所困

Recommendation:
1. Change the architecture to Nginx+PHP-FPM, and build the Nginx+PHP-FPM environment
2. Put all static files (JS, CSS, static pictures) on CDN. Now the price of CDN is very cheap. I recommend youpai.com and Qiniu
3. Do a good job of WordPress caching. Many WordPress blog pages can be statically cached. There must be many plug-ins to achieve this

淡淡烟草味

If the compatibility problem is not major, you can consider upgrading the PHP version. 5.5 has huge performance improvements.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!