Merge remote-tracking branch 'origin/graphql-opti' into compose

This commit is contained in:
Alessandro Pezzè 2021-08-30 18:14:20 +02:00
commit 14c332032d
2 changed files with 21 additions and 27 deletions

View file

@ -1,7 +1,7 @@
worker_processes 2;
worker_processes 1;
events {
worker_connections 4096;
worker_connections 1024;
multi_accept on; # accept each connection as soon as you can
accept_mutex off;
use epoll;
@ -29,16 +29,16 @@ http {
gzip_disable "msi6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
upstream pokeapi_upstream {
#upstream pokeapi_upstream {
# 'app' is the Django container name in Docker
server app:80 fail_timeout=0;
}
# server app:80 fail_timeout=0;
#}
upstream graphql_upstream {
server graphql-engine:8080 fail_timeout=0;
@ -57,6 +57,7 @@ http {
limit_req_zone $limit_key zone=graphqlDefaultLimit:50m rate=1r/m;
limit_conn_zone $binary_remote_addr zone=addr:20m;
proxy_cache_path /tmp/cache levels=1:2 keys_zone=small:40m inactive=10d max_size=2g use_temp_path=off;
server {
listen 80 deferred;
@ -67,7 +68,7 @@ http {
client_body_timeout 5s;
client_header_timeout 5s;
limit_conn addr 10;
limit_conn addr 15;
# Admin console
location /graphql/admin/ {
@ -91,11 +92,19 @@ http {
}
location /graphql/v1beta {
proxy_read_timeout 70s;
proxy_cache small;
proxy_cache_valid 200 10d;
proxy_cache_valid any 0;
proxy_cache_methods POST;
proxy_cache_key "$request_method$request_uri$request_body";
limit_req zone=graphqlDefaultLimit burst=100 nodelay;
limit_req_status 429;
expires 1m; # client-side caching, one minute for each API resource
expires 30m; # client-side caching, one minute for each API resource
add_header Cache-Control "public";
add_header Pragma public;
add_header X-Proxy-Cache $upstream_cache_status;
add_header X-Cache-Date $upstream_http_date;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
@ -106,23 +115,9 @@ http {
proxy_pass http://graphql_upstream/v1/graphql;
}
location /api/ {
expires 1m; # client-side caching, one minute for each API resource
add_header Cache-Control "public";
add_header Pragma public;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://pokeapi_upstream;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://pokeapi_upstream;
return 404;
}
}
}

View file

@ -43,13 +43,12 @@ services:
volumes:
- ./Resources/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./Resources/nginx/ssl:/ssl:ro
volumes_from:
- app:ro
links:
- app
graphql-engine:
image: hasura/graphql-engine:v2.0.0-alpha.5
cpus: 0.7
memswap_limit: 3g
mem_limit: 450m
ports:
- "8080:8080"
depends_on: