SlideShare a Scribd company logo
1 of 18
Download to read offline
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

More Related Content

Viewers also liked

Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Codemotion
 
Writing Prefork Workers / Servers
Writing Prefork Workers / ServersWriting Prefork Workers / Servers
Writing Prefork Workers / ServersKazuho Oku
 
Developing the fastest HTTP/2 server
Developing the fastest HTTP/2 serverDeveloping the fastest HTTP/2 server
Developing the fastest HTTP/2 serverKazuho Oku
 
The best power diy marketing tips for entrepreneurs
The best power diy marketing tips for entrepreneursThe best power diy marketing tips for entrepreneurs
The best power diy marketing tips for entrepreneursDIYMarketers
 
My presentation at Busan's Asia Exhibition Forum 2013
My presentation at Busan's Asia Exhibition Forum 2013My presentation at Busan's Asia Exhibition Forum 2013
My presentation at Busan's Asia Exhibition Forum 2013Eddie Choi
 
Judes Drafting Table The Bowling Question
Judes Drafting Table   The Bowling QuestionJudes Drafting Table   The Bowling Question
Judes Drafting Table The Bowling Questionsixteen.wiishes
 
Lewis Woodpecker by Taylor
Lewis Woodpecker by TaylorLewis Woodpecker by Taylor
Lewis Woodpecker by Taylorvebrya
 
Santiago Calatrava
Santiago CalatravaSantiago Calatrava
Santiago Calatravacarmine
 
Poplava sisljavic ppt
Poplava sisljavic pptPoplava sisljavic ppt
Poplava sisljavic pptGavranica
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideSharepiwnioyh
 
Task 4 Louise Nicholson
Task 4 Louise NicholsonTask 4 Louise Nicholson
Task 4 Louise NicholsonLouise1
 
Presentazione Cerisdi (7Nov2008)
Presentazione Cerisdi (7Nov2008)Presentazione Cerisdi (7Nov2008)
Presentazione Cerisdi (7Nov2008)euresgroup
 
Cytoscape プロジェクト現状報告 2011年2月
Cytoscape プロジェクト現状報告 2011年2月Cytoscape プロジェクト現状報告 2011年2月
Cytoscape プロジェクト現状報告 2011年2月Keiichiro Ono
 
Using CKAN as a data store
Using CKAN as a data storeUsing CKAN as a data store
Using CKAN as a data storeJoss Winn
 
Stepz - An Introduction
Stepz - An IntroductionStepz - An Introduction
Stepz - An IntroductionPratik Gupta
 

Viewers also liked (20)

Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
 
Writing Prefork Workers / Servers
Writing Prefork Workers / ServersWriting Prefork Workers / Servers
Writing Prefork Workers / Servers
 
Developing the fastest HTTP/2 server
Developing the fastest HTTP/2 serverDeveloping the fastest HTTP/2 server
Developing the fastest HTTP/2 server
 
The best power diy marketing tips for entrepreneurs
The best power diy marketing tips for entrepreneursThe best power diy marketing tips for entrepreneurs
The best power diy marketing tips for entrepreneurs
 
My presentation at Busan's Asia Exhibition Forum 2013
My presentation at Busan's Asia Exhibition Forum 2013My presentation at Busan's Asia Exhibition Forum 2013
My presentation at Busan's Asia Exhibition Forum 2013
 
Judes Drafting Table The Bowling Question
Judes Drafting Table   The Bowling QuestionJudes Drafting Table   The Bowling Question
Judes Drafting Table The Bowling Question
 
Lewis Woodpecker by Taylor
Lewis Woodpecker by TaylorLewis Woodpecker by Taylor
Lewis Woodpecker by Taylor
 
Civil War Causes
Civil War CausesCivil War Causes
Civil War Causes
 
Projet Enfance
Projet EnfanceProjet Enfance
Projet Enfance
 
My garden
My gardenMy garden
My garden
 
Pomoc
PomocPomoc
Pomoc
 
Global warming
Global warmingGlobal warming
Global warming
 
Santiago Calatrava
Santiago CalatravaSantiago Calatrava
Santiago Calatrava
 
Poplava sisljavic ppt
Poplava sisljavic pptPoplava sisljavic ppt
Poplava sisljavic ppt
 
香港六合彩 » SlideShare
香港六合彩 » SlideShare香港六合彩 » SlideShare
香港六合彩 » SlideShare
 
Task 4 Louise Nicholson
Task 4 Louise NicholsonTask 4 Louise Nicholson
Task 4 Louise Nicholson
 
Presentazione Cerisdi (7Nov2008)
Presentazione Cerisdi (7Nov2008)Presentazione Cerisdi (7Nov2008)
Presentazione Cerisdi (7Nov2008)
 
Cytoscape プロジェクト現状報告 2011年2月
Cytoscape プロジェクト現状報告 2011年2月Cytoscape プロジェクト現状報告 2011年2月
Cytoscape プロジェクト現状報告 2011年2月
 
Using CKAN as a data store
Using CKAN as a data storeUsing CKAN as a data store
Using CKAN as a data store
 
Stepz - An Introduction
Stepz - An IntroductionStepz - An Introduction
Stepz - An Introduction
 

Similar to Server Starter - a superdaemon to hot-deploy server programs

Real time data processing with kafla spark integration
Real time data processing with kafla spark integrationReal time data processing with kafla spark integration
Real time data processing with kafla spark integrationTCS
 
AWS SnapStart at Community Day Istanbul 2023
AWS SnapStart at Community Day Istanbul 2023AWS SnapStart at Community Day Istanbul 2023
AWS SnapStart at Community Day Istanbul 2023Goran Opacic
 
Java App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDJava App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDSeun Matt
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!Jeff Anderson
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache CamelFuseSource.com
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsJean Deruelle
 
Tungsten University: Configure and provision Tungsten clusters
Tungsten University: Configure and provision Tungsten clustersTungsten University: Configure and provision Tungsten clusters
Tungsten University: Configure and provision Tungsten clustersContinuent
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesWojciech Barczyński
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)Flowdock
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixDiana Tkachenko
 
appserver.io tutorial
appserver.io tutorialappserver.io tutorial
appserver.io tutorialappserver.io
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
 
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...Twilio Inc
 
Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure InteroperabilityMihai Dan Nadas
 
continuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israelcontinuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon IsraelAlon Aizenberg
 
Continuous Delivery at SAP IT, Alon Aizenberg
Continuous Delivery at SAP IT, Alon AizenbergContinuous Delivery at SAP IT, Alon Aizenberg
Continuous Delivery at SAP IT, Alon AizenbergDevOpsDays Tel Aviv
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and TomorrowVMware Tanzu
 

Similar to Server Starter - a superdaemon to hot-deploy server programs (20)

Real time data processing with kafla spark integration
Real time data processing with kafla spark integrationReal time data processing with kafla spark integration
Real time data processing with kafla spark integration
 
AWS SnapStart at Community Day Istanbul 2023
AWS SnapStart at Community Day Istanbul 2023AWS SnapStart at Community Day Istanbul 2023
AWS SnapStart at Community Day Istanbul 2023
 
Building Web APIs that Scale
Building Web APIs that ScaleBuilding Web APIs that Scale
Building Web APIs that Scale
 
Java App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDJava App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CD
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
V fabric overview
V fabric overviewV fabric overview
V fabric overview
 
Tungsten University: Configure and provision Tungsten clusters
Tungsten University: Configure and provision Tungsten clustersTungsten University: Configure and provision Tungsten clusters
Tungsten University: Configure and provision Tungsten clusters
 
Zero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with KubernetesZero downtime deployment of micro-services with Kubernetes
Zero downtime deployment of micro-services with Kubernetes
 
A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)A Tale of a Server Architecture (Frozen Rails 2012)
A Tale of a Server Architecture (Frozen Rails 2012)
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch Fix
 
appserver.io tutorial
appserver.io tutorialappserver.io tutorial
appserver.io tutorial
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
JavaFX Uni Parthenope
JavaFX Uni ParthenopeJavaFX Uni Parthenope
JavaFX Uni Parthenope
 
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
 
Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure Interoperability
 
continuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israelcontinuous delivery at SAP IT for devopscon Israel
continuous delivery at SAP IT for devopscon Israel
 
Continuous Delivery at SAP IT, Alon Aizenberg
Continuous Delivery at SAP IT, Alon AizenbergContinuous Delivery at SAP IT, Alon Aizenberg
Continuous Delivery at SAP IT, Alon Aizenberg
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 

More from Kazuho Oku

HTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときHTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときKazuho Oku
 
QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7Kazuho Oku
 
HTTP/2の課題と将来
HTTP/2の課題と将来HTTP/2の課題と将来
HTTP/2の課題と将来Kazuho Oku
 
TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話Kazuho Oku
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondKazuho Oku
 
Recent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyRecent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyKazuho Oku
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsivenessKazuho Oku
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsivenessKazuho Oku
 
TLS & LURK @ IETF 95
TLS & LURK @ IETF 95TLS & LURK @ IETF 95
TLS & LURK @ IETF 95Kazuho Oku
 
HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向Kazuho Oku
 
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先Kazuho Oku
 
Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Kazuho Oku
 
HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計Kazuho Oku
 
H2O - making the Web faster
H2O - making the Web fasterH2O - making the Web faster
H2O - making the Web fasterKazuho Oku
 
H2O - making HTTP better
H2O - making HTTP betterH2O - making HTTP better
H2O - making HTTP betterKazuho Oku
 
H2O - the optimized HTTP server
H2O - the optimized HTTP serverH2O - the optimized HTTP server
H2O - the optimized HTTP serverKazuho Oku
 
JSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedJSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedKazuho Oku
 
JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法Kazuho Oku
 
JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013Kazuho Oku
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to ProveKazuho Oku
 

More from Kazuho Oku (20)

HTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときHTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないとき
 
QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7QUIC標準化動向 〜2017/7
QUIC標準化動向 〜2017/7
 
HTTP/2の課題と将来
HTTP/2の課題と将来HTTP/2の課題と将来
HTTP/2の課題と将来
 
TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話TLS 1.3 と 0-RTT のこわ〜い話
TLS 1.3 と 0-RTT のこわ〜い話
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and Beyond
 
Recent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using rubyRecent Advances in HTTP, controlling them using ruby
Recent Advances in HTTP, controlling them using ruby
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsiveness
 
Programming TCP for responsiveness
Programming TCP for responsivenessProgramming TCP for responsiveness
Programming TCP for responsiveness
 
TLS & LURK @ IETF 95
TLS & LURK @ IETF 95TLS & LURK @ IETF 95
TLS & LURK @ IETF 95
 
HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向HTTPとサーバ技術の最新動向
HTTPとサーバ技術の最新動向
 
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
ウェブを速くするためにDeNAがやっていること - HTTP/2と、さらにその先
 
Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5Cache aware-server-push in H2O version 1.5
Cache aware-server-push in H2O version 1.5
 
HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計HTTP/2時代のウェブサイト設計
HTTP/2時代のウェブサイト設計
 
H2O - making the Web faster
H2O - making the Web fasterH2O - making the Web faster
H2O - making the Web faster
 
H2O - making HTTP better
H2O - making HTTP betterH2O - making HTTP better
H2O - making HTTP better
 
H2O - the optimized HTTP server
H2O - the optimized HTTP serverH2O - the optimized HTTP server
H2O - the optimized HTTP server
 
JSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons LearnedJSON SQL Injection and the Lessons Learned
JSON SQL Injection and the Lessons Learned
 
JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法JSX 速さの秘密 - 高速なJavaScriptを書く方法
JSX 速さの秘密 - 高速なJavaScriptを書く方法
 
JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013JSX の現在と未来 - Oct 26 2013
JSX の現在と未来 - Oct 26 2013
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to Prove
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Server Starter - a superdaemon to hot-deploy server programs

  • 1. Server::Starter a superdaemon to hot-deploy server programs Cybozu Labs, Inc. Kazuho Oku
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. Reaching the Goals Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 6
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. Demo Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 10
  • 11. Using Server::Starter Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 11
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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
  • 17. ToDo  Support for FastCGI  although ... (ry  init.d-style startup mode Sep 10 2009 Server::Starter - a superdaemon to hot-deploy server programs 17
  • 18. 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