Tune worker_connections based on dyno size.

These numbers arrived at by wildly unscientific methods involving apachebench.
parent 4ba31d90
...@@ -6,6 +6,15 @@ HERE=$(dirname "$0") ...@@ -6,6 +6,15 @@ HERE=$(dirname "$0")
# Reify the environment into an nginx config file, since nginx doesn't support # Reify the environment into an nginx config file, since nginx doesn't support
# environment variables particularly well # environment variables particularly well
case $(ulimit -u) in
512) # 2X Dyno
export WORKER_CONNECTIONS=2048
;;
*) # 1X, PX, IX, Hobby, Free Dynos
export WORKER_CONNECTIONS=2048
;;
esac
"${HERE}/config/make-config" "${HERE}/config/make-config"
# make a shared pipe; we'll write the name of the process that exits to it once # make a shared pipe; we'll write the name of the process that exits to it once
......
...@@ -14,6 +14,7 @@ class NginxConfig ...@@ -14,6 +14,7 @@ class NginxConfig
def initialize(json_file) def initialize(json_file)
json = {} json = {}
json = JSON.parse(File.read(json_file)) if File.exist?(json_file) json = JSON.parse(File.read(json_file)) if File.exist?(json_file)
json["worker_connections"] ||= ENV["WORKER_CONNECTIONS"] || 512
json["port"] ||= ENV["PORT"] || 5000 json["port"] ||= ENV["PORT"] || 5000
json["root"] ||= "public_html/" json["root"] ||= "public_html/"
json["proxies"] ||= {} json["proxies"] ||= {}
......
daemon off; daemon off;
worker_processes 4; worker_processes auto;
events { events {
use epoll; use epoll;
accept_mutex on; accept_mutex on;
worker_connections 1024; worker_connections <%= worker_connections %>;
} }
http { http {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment