* [ANN] yahns 1.12.4 -_- sleepy app server for Ruby
@ 2016-05-02 19:47 4% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2016-05-02 19:47 UTC (permalink / raw)
To: ruby-talk, yahns-public
A Free Software, multi-threaded, non-blocking network
application server designed for low _idle_ power consumption.
It is primarily optimized for applications with occasional users
which see little or no traffic. yahns currently hosts Rack/HTTP
applications, but may eventually support other application
types. Unlike some existing servers, yahns is extremely
sensitive to fatal bugs in the applications it hosts.
* git clone git://yhbt.net/yahns
* https://yahns.yhbt.net/README
* https://yahns.yhbt.net/NEWS.atom.xml
* we only accept plain-text email yahns-public@yhbt.net
* and archive all the mail we receive: https://yhbt.net/yahns-public/
* nntp://news.public-inbox.org/inbox.comp.lang.ruby.yahns
Changes:
yahns 1.12.4 - rack.hijack and proxy_pass bugfixes
This release fixes some resource leaks in uncommonly used parts
of yahns as well as including some documentation improvements.
No need to upgrade unless you rely on rack.hijack for responses
or use the (currently-undocumented) proxy_pass module(*).
9 non-merge changes since 1.12.3:
proxy_pass: honor wbuf_persist when ending response
proxy_http_response: fix non-terminated fast responses, too
test_proxy_pass: test for auto chunking on 1.0 backends
wbuf: drop persistence if writing to client fails
proxy_http_response: cleanup: avoid redundant setting of "alive"
proxy_http_response: do not persist upstream on slow clients
proxy_pass: drop resources immediately on errors
document Rack::Chunked/ContentLength semi-requirements
extras/exec_cgi: document cgit example
Documentation/yahns-rackup.pod | 10 ++++++++++
GIT-VERSION-GEN | 2 +-
examples/yahns_rack_basic.conf.rb | 6 ++++++
extras/exec_cgi.rb | 8 ++++++++
lib/yahns/proxy_http_response.rb | 40 ++++++++++++++++++++++-----------------
lib/yahns/proxy_pass.rb | 5 +++--
lib/yahns/wbuf_common.rb | 1 +
test/test_proxy_pass.rb | 15 +++++++++++++++
8 files changed, 67 insertions(+), 20 deletions(-)
(*) 1.13.0 will include refactoring in proxy_pass and possibly
documenting it as stable-enough-for-public use:
https://yhbt.net/yahns-public/20160220081619.GA10850@dcvr.yhbt.net/t/
Please note the disclaimer:
yahns is extremely sensitive to fatal bugs in the apps it hosts. There
is no (and never will be) any built-in "watchdog"-type feature to kill
stuck processes/threads. Each yahns process may be handling thousands
of clients; unexpectedly killing the process will abort _all_ of those
connections. Lives may be lost!
yahns hackers are not responsible for your application/library bugs.
Use an application server which is tolerant of buggy applications
if you cannot be bothered to fix all your fatal bugs.
^ permalink raw reply [relevance 4%]
* [PATCH 4/5] proxy_http_response: do not persist upstream on slow clients
2016-04-27 0:26 4% [PATCH 0/5] proxy_pass resource cleanup fixes Eric Wong
@ 2016-04-27 0:27 7% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2016-04-27 0:27 UTC (permalink / raw)
To: yahns-public
For slow clients, we want to be able to drop the connection
to the upstream as soon as we are done buffering and not waste
resources by leaving it in an :ignore state. We also need to
remember the client for the fdmap to prevent shutdowns.
Ugh, this is really hard to test locally.
---
lib/yahns/proxy_http_response.rb | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index e551323..3462e40 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -56,6 +56,7 @@ def wait_on_upstream(req_res, alive, wbuf)
:wait_readable # self remains in :ignore, wait on upstream
end
+ # start streaming the response once upstream is done sending headers to us.
# returns :wait_readable if we need to read more from req_res
# returns :ignore if we yield control to the client(self)
# returns nil if completely done
@@ -177,9 +178,9 @@ def proxy_response_start(res, tip, kcar, req_res)
end
end
- return proxy_busy_mod_done(alive) unless wbuf
- req_res.resbuf = wbuf
- proxy_busy_mod_blocked(wbuf, wbuf.busy)
+ # all done reading response from upstream, req_res will be discarded
+ # when we return nil:
+ wbuf ? proxy_busy_mod_blocked(wbuf, wbuf.busy) : proxy_busy_mod_done(alive)
rescue => e
proxy_err_response(502, req_res, e, wbuf)
end
@@ -247,7 +248,7 @@ def proxy_response_finish(kcar, wbuf, req_res)
end
busy = wbuf.busy and return proxy_busy_mod_blocked(wbuf, busy)
- proxy_busy_mod_done(wbuf.wbuf_persist) # returns nil
+ proxy_busy_mod_done(wbuf.wbuf_persist) # returns nil to close req_res
end
def proxy_wait_next(qflags)
@@ -288,23 +289,23 @@ def proxy_busy_mod_done(alive)
when :close then close
end
- nil # close the req_res, too
+ nil # signal close for ReqRes#yahns_step
end
def proxy_busy_mod_blocked(wbuf, busy)
- q = Thread.current[:yahns_queue]
# we are completely done reading and buffering the upstream response,
# but have not completely written the response to the client,
# yield control to the client socket:
@state = wbuf
- case busy
- when :wait_readable then q.queue_mod(self, Yahns::Queue::QEV_RD)
- when :wait_writable then q.queue_mod(self, Yahns::Queue::QEV_WR)
- else
- abort "BUG: invalid wbuf.busy: #{busy.inspect}"
- end
- # no touching self after queue_mod
- :ignore
+ proxy_wait_next(case busy
+ when :wait_readable then Yahns::Queue::QEV_RD
+ when :wait_writable then Yahns::Queue::QEV_WR
+ else
+ abort "BUG: invalid wbuf.busy: #{busy.inspect}"
+ end)
+ # no touching self after proxy_wait_next, we may be running
+ # HttpClient#yahns_step in a different thread at this point
+ nil # signal close for ReqRes#yahns_step
end
# n.b.: we can use String#size for optimized dispatch under YARV instead
--
EW
^ permalink raw reply related [relevance 7%]
* [PATCH 0/5] proxy_pass resource cleanup fixes
@ 2016-04-27 0:26 4% Eric Wong
2016-04-27 0:27 7% ` [PATCH 4/5] proxy_http_response: do not persist upstream on slow clients Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2016-04-27 0:26 UTC (permalink / raw)
To: yahns-public
Lightly-tested, I'm going to let these run on YHBT.net for
a bit before cutting a new release.
And all this proxy_pass stuff could still use some cleanup and
refactoring, it's hairy!
Eric Wong (5):
test_proxy_pass: test for auto chunking on 1.0 backends
wbuf: drop persistence if writing to client fails
proxy_http_response: cleanup: avoid redundant setting of "alive"
proxy_http_response: do not persist upstream on slow clients
proxy_pass: drop resources immediately on errors
lib/yahns/proxy_http_response.rb | 37 +++++++++++++++++++++----------------
lib/yahns/proxy_pass.rb | 5 +++--
lib/yahns/wbuf_common.rb | 1 +
test/test_proxy_pass.rb | 15 +++++++++++++++
4 files changed, 40 insertions(+), 18 deletions(-)
^ permalink raw reply [relevance 4%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-04-08 20:01 [ANN] yahns 1.12.3 -_- sleepy app server for Ruby Eric Wong
2016-05-02 19:47 4% ` [ANN] yahns 1.12.4 " Eric Wong
2016-04-27 0:26 4% [PATCH 0/5] proxy_pass resource cleanup fixes Eric Wong
2016-04-27 0:27 7% ` [PATCH 4/5] proxy_http_response: do not persist upstream on slow clients Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/yahns.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).