1

I have a opencart application deployed with nginx,fastcgi. Im using RDS as Mysql server.

Lately,I have been having this errors in my log and I ran load test with siege for 400 concurrent users.I'm getting this error

FastCGI sent in stderr: "PHP message: PHP Warning: mysqli::mysqli

while running the same load test with siege using apache as server.The test yields positive results

These are siege results with nginx

Transactions:               3246 hits
Availability:              77.80 %
Elapsed time:             146.43 secs
Data transferred:          35.27 MB
Response time:              6.86 secs
Transaction rate:          22.17 trans/sec
Throughput:             0.24 MB/sec
Concurrency:              152.01
Successful transactions:        1049
Failed transactions:             926
Longest transaction:           36.83
Shortest transaction:           0.65

and with apache

Transactions:               7921 hits
Availability:              99.01 %
Elapsed time:             462.60 secs
Data transferred:         218.75 MB
Response time:              9.94 secs
Transaction rate:          17.12 trans/sec
Throughput:             0.47 MB/sec
Concurrency:              170.12
Successful transactions:        4925
Failed transactions:              79
Longest transaction:          114.25
Shortest transaction:           0.59

These are nginx and fpm conf :

user www-data;
worker_processes 1;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        # Compression

        # Enable Gzip compressed.
        gzip on;
        # Enable compression both for HTTP/1.0 and HTTP/1.1.
        #gzip_http_version  1.1;

        # Compression level (1-9).
        # 5 is a perfect compromise between size and cpu usage, offering about
        # 75% reduction for most ascii files (almost identical to level 9).
        gzip_comp_level    4;

        # Don't compress anything that's already small and unlikely to shrink much
        # if at all (the default is 20 bytes, which is bad as that usually leads to
        # larger files after gzipping).
        gzip_min_length    256;

        # Compress data even for clients that are connecting to us via proxies,
        # identified by the "Via" header (required for CloudFront).
        gzip_proxied       any;

        # Tell proxies to cache both the gzipped and regular version of a resource
        # whenever the client's Accept-Encoding capabilities header varies;
        # Avoids the issue where a non-gzip capable client (which is extremely rare
        # today) would display gibberish if their proxy gave them the gzipped version.
        gzip_vary          on;

        # Compress all output labeled with one of the following MIME-types.
        gzip_types
          application/atom+xml
          application/javascript
          application/x-javascript
          application/json
          application/rss+xml
          application/vnd.ms-fontobject
          application/x-font-ttf
          application/x-web-app-manifest+json
          application/xhtml+xml
          application/xml
          font/opentype
          image/svg+xml
          image/x-icon
          text/css
          text/plain
          text/x-component
          text/xml
          text/javascript
          text/x-javascript
        # text/html is always compressed by HttpGzipModule


        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##
        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}
  • 1
    nginx is capable to serve more clients in parallel, while apache worker blocks and wait for the full output for one connection. clearly you are hitting some limit with mysql while on nginx, but there's not enough information. that is the main reason you are getting less performance - first N requests just flood something in mysql. I guess that can be connection limit, open tables limit, open files limit etc. – drookie Sep 28 '15 at 18:16
  • yeah.I feel that since we are using RDS t2.micro,the micro can only have 32 concurrent connections. – 5ud0 Sep 29 '15 at 6:30
  • increase it then. In the same time that doesn't explain why apache isn't flooding it - 32 connections seems to be relatively low even for apache. – drookie Sep 29 '15 at 7:21
  • apache log is also flooding now that I see it.But the availability is high with apache compared to nginx and I cant reason why! – 5ud0 Sep 29 '15 at 7:26

Your Answer

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

Browse other questions tagged or ask your own question.