Re: millisecond timeouts in mod_proxy mod_proxy_http
How can I help clean it up? Are there other places where we can add ms timing support? The custom error-documents and status have been great for restful services where we wanted zero proxy errors returned to the client. Thanks - Neal On 1/15/11, Daniel Ruggeri drugg...@primary.net wrote: On 1/14/2011 7:06 PM, Jim Jagielski wrote: It looks like it needs some fine-tuning and some formatting changes, but assuming we have CLA approval, I'd say lets fold it in and clean up post submission;) ... - extends RewriteRules to implement a custom error document or return status per rule if timeout occurs FWIW, Jim, I'm a big fan of this part. -- Daniel Ruggeri
millisecond timeouts in mod_proxy mod_proxy_http
Apache committers: I'd like to submit this for possible inclusion in Apache httpd https://github.com/nealrichter/mod_proxy_http_sla - allows millisecond timeouts for ProxyPass/ProxyTimeout directives - allows millisecond timeouts for RewriteRule driven proxy - extends RewriteRules to implement a custom error document or return status per rule if timeout occurs Complete README here: https://github.com/nealrichter/mod_proxy_http_sla/blob/master/README We've been using both patches at the Rubicon Project for 18 months in one case and 6 in other. Handling billions of HTTP requests per day (yes really). Hat tip to Ronald Park who paved the way for this with similar work in httpd 2.0.x patches. Thanks - Neal Richter
mod_proxy_http, ProxyTimeout and apr_socket_timeout_set
Hi all, Basic question on the ProxyTimeout for mod_proxy_http. Is it: - first byte? - last byte? My guess is that it's a first byte timeout based upon this: /** * Setup socket timeout for the specified socket * @param sock The socket to set up. * @param t Value for the timeout. * PRE * t 0 -- read and write calls return APR_TIMEUP if specified time * elapsess with no data read or written * t == 0 -- read and write calls never block * t 0 -- read and write calls block * /PRE */ APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t); Neal
Re: mod_proxy_http, ProxyTimeout and apr_socket_timeout_set
OK thanks.. making sure it would not timeout an ongoing download. We had an issue with a truncated javascript file being served then cached by Akamai. The JS is generated by a backend process that Apache proxies to. I don't think Apache is the problem there.. Thanks - Neal On Tue, Jul 20, 2010 at 9:16 PM, Jeff Trawick traw...@gmail.com wrote: On Wed, Jul 21, 2010 at 2:41 AM, Neal Richter nrich...@gmail.com wrote: Hi all, Basic question on the ProxyTimeout for mod_proxy_http. Is it: - first byte? - last byte? any byte (i.e., any time proxy attempts I/O, the request fails if it can't send/receive a single byte within this timeout value)
Re: Hacking in an SLA for proxied requests in mod_proxy_http
Brian Akins wrote: Is the proxy-timeout for the entire request to be returned, the first byte, or just an i/o timeout? To set a 900ms timeout the code does approximately this: apr_interval_time_t new_timeout = apr_time_make(0, 900 * (APR_USEC_PER_SEC/1000)); apr_socket_timeout_set(backend-sock, new_timeout); I don't _really_ know what effect that has but I believe it's first-byte response timeout. I'm hoping that 'rpluem', 'jim', 'niq', etc (people who committed code in the mod) will jump in and give guidance about correctness and side effects of the hack. [Sorry all for the wretched grammar in the first paragraph of original email, ouch!] - Neal
Hacking in an SLA for proxied requests in mod_proxy_http
Hey all, I wanted to enforce an SLA on certain http requests to apache. Essentially provide a the external client users an guarantee that a valid response will be given within XXms and all errors are suppressed. This is for an ReST API that returns JSON or XML data. Ronald Park attempted to do something similar for Apache 2.0 in Feb 2008 here: http://bit.ly/HglyS The issues with making apache do this are as follows: * ProxyTimeout is global or scoped to the particular vhost * ErrorDocuments still return the error code (503, 404, etc) * No way to tie ErrorDocuments and ProxyTimeouts to particular requests. I followed Ronald's lead and reimplemented in apache 2.2 with a few new additions. The below example is a rewrite rule that makes no changes to the URL itself for a JS API presumably returning data in JSON. RewriteRule ^/api/(.*).js\?*(.*)$ http://backendproxy/api/$1.js?$2 [P,QSA,E=proxy-timeout:900ms,E=error-suppress:true,E=error-headers:/errorapi.js.HTTP,E=error-document:/errorapi.js] With the SLA enforcement modifications enabled, the URL will return data from the backend system within 900ms or a timeout occurs. At this point apache will stop waiting for the backend response and serve back the static files /errorapi.js.HTTP as HTTP headers and /errorapi.js as contents. $cat /var/www/html/errorapi.js.HTTP Status: 204 Content-type: application/javascript $cat /var/www/html/errorapi.js var xxx_api_data={data:[]}; /* ERR */ There are four environment variables the SLA hack looks for: * proxy-timeout: - time in seconds or milliseconds to wait until timing out * error-suppress: - true/false switch on suppressing all non 2xx errors from the backend. * error-headers: - file of syntax correct HTTP headers to return to the client * error-document: - file of content body to be returned to the client Leaving off the proxy-timeout will only suppress errors from the backend after the global timeout occurs. Leaving off error-suppress:true will ensure that the 5xx timeout error from mod_proxy_http is returned intact to the client. Code here: http://github.com/nealrichter/mod_proxy_http_sla/tree Diff here: http://bit.ly/UdAHB Blog Post: http://aicoder.blogspot.com/2009/07/hacking-apaches-modproxyhttp-to-enforce.html Please examine and comment.. it's on production servers handling approx of 50Million API hits per day.. no issues thus far. I'd like some feedback if I'm resetting the timeout back to the previous one on the socket correctly and if there is a better way to do this in the code. I essentially used Ronald's code plus some stuff from mod_asis. Thanks - Neal Richter