I have an website wich is getting more traffic as usual in the past months. I want this website to server more users in the same amount of time without changing the Hardware. At the Moment i use Apache2 with Wordpress and Memcached. I wanted to know if i can use Nginx to get more performance on this site. When i have Nginx running on the Webserver with Wordpress and i run a test with 10000 users over a period of 60 seconds, i get only 600 succesfull answers the other 9400 connections get Errors. (mostly timeout). IMG
when i use Memcached additionally to the previous configuration i get 9969 successfull Answers, but the maximal users per second dont go over 451 IMG
But on my Site i have sometimes over 1000 Users per second. So can anybody tell me what im doing wrong?

在过去的几个月里,我有一个像往常一样获得更多流量的网站。我希望这个网站能够在相同的时间内为更多用户提供服务,而无需更改硬件。在片刻,我使用Apache2与Wordpress和Memcached。我想知道我是否可以使用Nginx在这个网站上获得更多性能。当我使用Wordpress在Web服务器上运行Nginx并且我在60秒内运行10000个用户的测试时,我只获得600个成功答案,其他9400个连接获得错误。 (大多是超时)。 IMG当我使用Memcached以前的配置我得到9969成功答案,但每秒最大用户不超过451 IMG但在我的网站上我有时超过1000用户每秒。所以有人能告诉我我做错了什么吗?

System:
AWS EC2 Cloud Server 2GHz, 650MB RAM
Ubuntu 13.10
Nginx 1.4.7
Memcached 1.4.14
Php-fpm for php 5.5.3

系统:AWS EC2云服务器2GHz,650MB RAM Ubuntu 13.10 Nginx 1.4.7 Memcached 1.4.14 Php-fpm for php 5.5.3

2 个解决方案

#1


0

The number you should consider is Avg error rate, your WP+Nginx+Memcached configuration looks not too bad, so by my opinion this is good choice. Maybe you can increase the -m parameter in memcached to match half of your RAM.

你应该考虑的数字是平均错误率,你的WP + Nginx + Memcached配置看起来不是太糟糕,所以我认为这是一个不错的选择。也许你可以在memcached中增加-m参数来匹配你的一半RAM。

BUT: memcached do not guarantee that the data will be available in memory and you have to be prepared for a cache-miss storm. One interesting approach to avoid a miss-storm is to set the expiration time with some random offset, say 10 + [0..10] minutes, which means some items will be stored for 10, and other for 20 minutes (the goal is that not all of items expire at the same time).

但是:memcached不保证数据在内存中可用,您必须为缓存未命中风暴做好准备。避免风暴的一个有趣的方法是设置一个随机偏移的过期时间,比如10 + [0..10]分钟,这意味着一些项目将存储10,其他项目将存储20分钟(目标是并非所有项目都在同一时间到期)。

Also, no matter how much memory you will allocate for memcached, it will use only the amount it needs, e.g. it allocates only the memory actually used. With the -k option however (which is disabled in your config), the entire memory is reserved when memcached is started, so it always allocate the whole amount of memory, no matter if it needs it or not.

此外,无论您为memcached分配多少内存,它都只会使用它所需的数量,例如:它只分配实际使用的内存。但是使用-k选项(在配置中禁用),启动memcached时保留整个内存,因此无论是否需要,它总是分配全部内存。

This number of 451 connections can actually vary, it depends. It is always good idea to look at the averages when performing benchmarks, i.e. better to have 0% Avg error rate and 451 served clients, than 65% Avg error rate and 8200+ served clients.

这个451个连接的数量实际上可能会有所不同,这取决于。在执行基准测试时查看平均值总是一个好主意,即更好地获得0%Avg错误率和451个服务客户端,而不是65%Avg错误率和8200+服务客户端。

However, in order to offload some more resources, you can use additional caching for Wordpress, there are plenty of plugins, I personally wrote one for that purpose.

但是,为了卸载更多资源,你可以为Wordpress使用额外的缓存,有很多插件,我亲自为此编写了一个。

Regarding the nginx configuration, you can tune some parameters there also:

关于nginx配置,您还可以调整一些参数:

worker_rlimit_nofile 100000;

worker_connections 4000;

# optmized to serve many clients with each thread, essential for linux use epoll;
# accept as many connections as possible,may flood worker connections if set too low
multi_accept on;

# cache informations about FDs, frequently accessed files
# can boost performance, but you need to test those values
open_file_cache max=200000 inactive=20s; 
open_file_cache_valid 30s; 
open_file_cache_min_uses 2;
open_file_cache_errors on;

# to boost IO on HDD we can disable access logs
access_log off;

# copies data between one FD and other from within the kernel
# faster then read() + write()
sendfile on;

# send headers in one peace, its better then sending them one by one 
tcp_nopush on;

# don't buffer data sent, good for small data bursts in real time
tcp_nodelay on;
# number of requests client can make over keep-alive -- for testing
keepalive_requests 100000;

# allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on;

# request timed out -- default 60
client_body_timeout 10;

# if client stop responding, free up memory -- default 60
send_timeout 2;

# reduce the data that needs to be sent over network
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";

更多相关文章

  1. MySql-cluster中NDBD进程占用内存能否通过配置修改
  2. MySQL在C++中使用后务必释放 result,否则会造成内存泄露
  3. 我在Firefox中遇到内存泄漏或内存使用率高吗?
  4. AngularJS - 删除绑定以避免内存泄漏
  5. Python是如何进行内存管理的
  6. python之内存概念
  7. 用于Python项目的低内存和最快查询数据库
  8. 在Python中的大文件中拆分行的内存问题
  9. 使用python 3.6将多个文件并行加载到内存中的最佳方法是什么?

随机推荐

  1. 利用Excel学习Python:准备篇
  2. 动态图表揭秘:“动”的关键——取数
  3. 利用Excel学习Python:变量
  4. 如何制作高大上的图表
  5. 从Excel的数据类型说Python
  6. 数据分析,除了Excel透视表,还有什么工具?
  7. 列表是个什么鬼?
  8. 如何培养数据分析的思维?
  9. 新手如何学习SQL
  10. 2019年终总结