You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
This documents HTTP timeouts involved in a web request from end-users to a service behind WMF traffic layers.
The entry point for external clients is ats-tls. Which of the "cp" hosts is routed through, depends on the service and end-user IP address:
|TLS termination layer||TLS handshake timeout||connect timeout (origin server)||TTFB (origin server)||successive reads (origin server)||Keepalive timeout (client)|
|ats-tls||60 seconds||3 seconds||180 seconds||180 seconds||120 seconds|
Currently a big difference between ats-tls and nginx (used previously for frontend TLS) is in how they handle POST requests. nginx buffered the whole request completely before relaying it to the origin (varnish-frontend) while ats-tls doesn't buffer it and relays the connection to varnish-frontend as soon as possible. On nginx, the timeout to fulfil the POST body was 60 seconds between read operations, this its default value and it isn't explicitly configured.
Our caching system is split in two layers (frontend, and backend). There is one implementation of the frontend layer (varnish) and one implementation of the backend layer (ats-be).
|caching layer||connect timeout||TTFB||successive reads|
|varnish-frontend||3 seconds (text) / 5 seconds (upload)||65 seconds (text) / 35 seconds (upload)||33 seconds (text) / 60 seconds (upload)|
|ats-backend||10 seconds||180 seconds||180 seconds|
After leaving the backend caching layer, the request reaches the appserver. Here are described the timeouts that apply to appservers and api:
|Envoy (TLS)||1 second (connect timeout) / 65 seconds (route timeout)
|Apache||202 seconds (appserver, api, parsoid) / 1202 seconds (jobrunner) / 86402 seconds (videoscaler).
|php-fpm||201 seconds (appservers) / 201 seconds (api) / 201 seconds (parsoid) / 86400 seconds (jobrunner, videoscaler).
|PHP||210 seconds (appserver, api, parsoid) / 1200 seconds (jobrunner, videoscaler).
|MediaWiki||60 seconds (GET) / 200 seconds (POST) / 1200 seconds (jobrunner) / 86400 seconds (videoscaler).
This is configured using php-excimer
The app server timeouts might be larger than the ones on the caching layer, this is mainly to properly service internal clients.
request_timeoutsetting the maximum time php-fpm will spend processing a request before terminating the worker process. This exists as a last-resort to kill PHP processes even if a long-running C function is not yielding to Excimer and/or if PHP raised
max_execution_timesetting in php.ini measures CPU time (not wall clock time), and does not include syscalls.
- Note that this is intentionally several seconds higher than the layers above and below because we generally want to avoid requests being stopped by this layer and prefer it to happen either earlier in MW or higher up in php-fpm.
- This layer is not able to differentiate between HTTP methods (GET/POST) or virtual hostnames (jobrunner vs videoscaler). As such, it has to accomodate both.
- For videoscalers this setting is actually lower than the surrounding layers (1200s/20min vs 86400s/24h). This is a compromise to prevent non-videoscaler jobs from being able to spend 24h on the CPU, which would be very unexpected. Regular jobrunners and videoscalers are forced to share the same php-fpm configuration. This is fine because while videoscaling jobs may use 24h to complete, they are expected to spend most of their time transcoding videos, which happens through syscalls that are not captured by PHP's cpu time.
- This is controlled by the
ExcimerTimerinterval value, in wmf-config/set-time-limit. Upon reaching the timeout, php-excimer will throw a
WMFTimeoutExceptionexception once the current syscall returns.