سؤال

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?

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

هل كانت مفيدة؟

المحلول 2

The Problem we had was not a real Problem. We only interpreted the Test results wrong.

The 400 Users limit wasnt an actual limit, the Server was able to keep the Users on a constant level, because it was fast enough to answer all requests right away.

The Results of the Tests are not comparable to my site, that is getting 1k Users, as it has better hardware than an AWS free instance of course. But i think 400 Users per sec is a very good result for such a "weak" server.. so

Question solved i think, because of my own stupidness of reading test results...

Thanks for your help anyway bodi0.

نصائح أخرى

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.

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).

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.

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.

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.

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

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]\.";
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top