I'm running a php-fpm server behind an nginx reverse proxy which is simply serving phpinfo to benchmark the response time. The response time (using postman) for the phpinfo page is around 150ms which seems to be way too high. I've used both AWS c5 instance and digital ocean dedicated instance and they both seem to have similar results.
I don't think it's a network issue since nginx has a response time of around 30ms when I request a simple html web page. This leads me to think its an issue with php itself. Any help is greatly appreciated - I am looking for an average response time for php pages of around 40-50ms. Below are the docker files and nginx config I am using:
Dockerfile:
FROM php:8.0.6-fpm-buster
RUN docker-php-ext-install opcache
COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
Nginx config:
server {
listen 80;
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
opcache.ini:
[opcache]
opcache.enable=1
; 0 means it will check on every request
; 0 is irrelevant if opcache.validate_timestamps=0 which is desirable in production
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
Docker-compose:
version: '2'
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/default.conf
networks:
- code-network
php:
build: .
volumes:
- ./code:/code
networks:
- code-network
networks:
code-network:
driver: bridge
./code/index.php
<?php
phpinfo();
?>