Server Starter - a superdaemon to hot-deploy server programs
Upcoming SlideShare
Loading in...5
×
 

Server Starter - a superdaemon to hot-deploy server programs

on

  • 6,041 views

Explains techniques used to write hot-deployable TCP servers, introduces a superdaemon to handle the problems.

Explains techniques used to write hot-deployable TCP servers, introduces a superdaemon to handle the problems.

Statistics

Views

Total Views
6,041
Views on SlideShare
4,461
Embed Views
1,580

Actions

Likes
2
Downloads
15
Comments
0

6 Embeds 1,580

http://developer.cybozu.co.jp 1559
http://www.slideshare.net 12
http://webcache.googleusercontent.com 5
http://translate.googleusercontent.com 2
http://74.125.153.132 1
http://j2k.naver.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Server Starter - a superdaemon to hot-deploy server programs Server Starter - a superdaemon to hot-deploy server programs Presentation Transcript

  • Server::Starter a superdaemon to hot-deploy server programs Cybozu Labs, Inc. Kazuho Oku
  • Hot deployment  what is it?  upgrading web application without restarting the application server  the goals  no downtime  no resource leaks  fail-safe Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 2
  • Current techniques  restart the interpreter (mod_perl)  pros: graceful  cons: XS may cause resource leaks, service-down on deployment failure, cannot implement in pure- perl  bind to unix socket (FastCGI)  pros: graceful, fail-safe  cons: only useful for local-machine communication Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 3
  • Current techniques (cont'd)  exec(myself) (Net::Server)  pros: graceful, pure-perl  cons: file descriptor leaks, service-down on deployment failure Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 4
  • Server::Starter  a superdaemon for hot-deploying TCP servers  superdaemon binds to TCP ports, then spawns the application server listen accept fork & exec SIGTERM app. logic accept spawn app. servers fork & exec app. logic SIGHUP Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 5
  • Reaching the Goals Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 6
  • No downtime  listening socket shared by old and new generation app. servers  old app. servers receive SIGTERM after new servers start listen accept fork & exec SIGTERM accept logic app. spawn app. servers fork & exec app. logic SIGHUP Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 7
  • No resource leaks  no chance of resource leaks  every generation of app. servers spawned from superdaemon listen accept fork & exec SIGTERM accept logic app. spawn app. servers fork & exec app. logic SIGHUP Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 8
  • Fail-safe  old app. server retired if and only if the new app. server starts up successfully  service continues even if the updated app. server fails to start, in cases like missing modules, etc.  a good practice is to do self-testing in the app. server before starting to serve client connections  is also an efficient way to preload modules listen accept fork & exec SIGTERM accept logic app. spawn app. servers fork & exec app. logic SIGHUP Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 9
  • Demo Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 10
  • Using Server::Starter Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 11
  • The Low-level Code # from command line % start_server --port=80 my_httpd # in my_httpd use Server::Starter qw(server_ports); my $listen_sock = IO::Socket::INET->new( Proto => 'tcp', ); $listen_sock->fdopen((values %{server_ports()})[0], 'w') or die "failed to bind to listening socket:$!"; while (1) { if (my $conn = $listen_sock->accept) { .... } } Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 12
  • Net::Server::SS::PreFork  subclass of Net::Server::PreFork # from command line % start_server --port=80 my_server.pl # in my_server.pl use base qw(Net::Server::SS::PreFork); sub process_request { #...code... } __PACKAGE__->run(); Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 13
  • Using together with HTTP::Server::Simple  HTTP::Server::Simple can use Net::Server::SS::PreFork as a backend  and many WAFs support HTTP::Server::Simple package MyServer; use base qw(HTTP::Server::Simple::CGI); sub net_server { 'Net::Server::SS::PreFork' }; sub handle_request { print "HTTP/1.0 200 HOKrnContent-Type: text/plainrnrnHello World"; } 1; Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 14
  • Using together with PSGI / Plack  started writing Plack::Impl::SSPreFork  on my github fork of Plack  uid, etc. aren't configurable yet :-( # from command line % start_server --port=80 -- plackup -i SSPreFork MyApp.pm Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 15
  • Launching from daemontools  daemontools  a (better) alternative to init.d scripts, by DJB  start_server script is designed to be run under daemontools  restart using –h (SIGHUP)  all logs to STDERR Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 16
  • ToDo  Support for FastCGI  although ... (ry  init.d-style startup mode Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 17
  • Conclusion  with Server::Starter, it is easy to write hot-deployable TCP servers Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 18