I am running a nginx+php-fpm+mysql on virtual server with 8 cores and 16G ram My aplication is a simple API provider server, which returns JSONs generated from mysql database on requests. Datasets are smost simple and only few kb big. But with a high load of 1000k users per sec. the simple requests takes 10 sekonds!!!.. which is very long. I assume its MYSQL that causes that slowly responses. Because I have a test database - same request to the test database takes 1sek. May be I need to tune up my mysql config to make requests faster? I am using mysqli and bind technique to generate output with php,

here are my configs:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user              nginx;
worker_processes  8;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;

events {
  worker_connections 15000;
  multi_accept on;
  use epoll;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  100;

    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;




# Disabling symbolic-links is recommended to prevent assorted security risks

# Settings user and group are ignored when systemd is used (fedora >= 15).
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
# uncomment next line on SLAVE

# Others options for Semisynchronous Replication

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html


Most likely culprit is your database queries and insufficient use of indexes.

You should check your SQL queries with MySQL EXPLAIN feature, so that you can see how the results are produced.

If there is nothing to improve in database indexes, then you need to consider implementing caching of ready datasets using either PHP or Memcache.


I assume it was a I/O issue.I solved it with making many same get.php files in different directories and redirecting requests randomly to them.. like a round robin. It improved the situation very well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.