I have a Laravel 5.5/PHP-fpm (PHP 7) API sitting behind nginx, both inside separate Docker containers. My API call which simply returns a json object takes about 2-4 seconds, which is very long for such a simple query. It should be less than a second. I'm not sure how to debug this problem. Any ideas why it's so slow?
- Using Docker for Mac
- docker-compose version 1.16.1, build 6d1ac21
- Docker version 17.09.0-ce, build afdb6d4
PHP API
Route::get('/api/names', function () {
return array(
1 => "Honey",
2 => "Nut",
3 => "Cheerios"
);
});
Nginx dockerfile
FROM nginx
RUN rm /etc/nginx/conf.d/*
COPY nginx.conf /etc/nginx/conf.d/
nginx.conf
upstream phpie {
server php-fpm:9000 weight=10 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
index index.php index.html;
root /var/www/api/public;
resolver 127.0.0.11 valid=5s ipv6=off;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass phpie:9000;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
PHP dockerfile
FROM php:7.1-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
docker-compose.yml
php-fpm:
build:
context: ./api
working_dir: /var/www/api
volumes:
- ./api:/var/www/api
ports:
- "9000"
nginx:
restart: always
build:
context: ./nginx
volumes:
- ./api:/var/www/api
depends_on:
- php-fpm
ports:
- "80:80"
command: /bin/bash -c "nginx -g 'daemon off;'"
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zJ4fHE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire