SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
ServerEngine Integration & Windows support
Ritta Narita
Fluentd Meetup 2016
About me.
Ritta Narita
joined Treasure Data after internship in 2015
2
@naritta
@narittan
Fluentd v0.14
ServerEngine is integrated
What’s ServerEngine?
A framework to implement robust multiprocess servers like Unicorn
worker
worker
worker
super
visor
Server
Dynamic reconfig

live restart
Heartbeat via pipe
auto restart
multi
process/thread
how to use ServerEngine
worker
super
visor
Server
module MyServer
def before_run
@sock = TCPServer.new(
config[:bind], config[:port])
end
attr_reader :sock
end
module MyWorker
def run
c = server.sock.accept
c.write "Awesome work!"
end
def stop
c.close
end
end
1. write server module and worker module
how to use ServerEngine
worker
super
visor
Server
se = ServerEngine.create(MyServer, MyWorker, {
daemonize: true,
log: 'myserver.log',
pid_path: 'myserver.pid',
worker_type: 'process',
workers: 4,
bind: '0.0.0.0',
port: 9071,
})
se.run
2. write configuration and run
module MyWorker
def spawn(process_manager)
process_manager.spawn(env, config[:spawn_cmd])
end
end
ServerEngine.create(MyServer, MyWorker, {
worker_type:‘spawn’,
spawn_cmd: cmd
})
ServerEngine.create(MyServer, MyWorker, {
worker_type:‘thread'
})
workerServer
workerServer
workerServer
spawn
thread
processServerEngine.create(MyServer, MyWorker, {
worker_type:‘process'
})
worker type
What’s the advantages for integrating serverengine into fluentd?
serverengine advantages
Auto restart
live restart
socket manager
signal handler
log rotation
Auto restart
live restart
socket manager
signal handler
log rotation
serverengine advantages
if worker died unexpectedly…
worker
worker
super
visor
Server
worker
if worker died unexpectedly…
worker
worker
worker
super
visor
Server
if worker died unexpectedly…
worker
worker
super
visor
Server
It’s detected by heartbeat and server launch worker again.
worker
Auto restart
live restart
socket manager
signal handler
log rotation
serverengine advantages
worker
super
visor
Server
tcp tcp
send SIGHUP
live restart
super
visor
Server worker
tcp
kill the worker, leaving server’s condition
live restart
worker
super
visor
Server worker
tcp
start new worker and read config again
live restart
worker
super
visor
Server worker
tcp
tcp
share the TCP with living zero downtime
live restart
Signal and RPC server
api/config.reloadlive restart/config reload HUP
/api/processes
.interruptWorkers
INT
/api/processes
.killWorkers
/api/plugins.
flushBuffers
system config reload USR2
TERM
USR1flush buffers
shutdown
worker
super
visor
Server
you can reload system config without restart
system config reload
send USR2
check mtime and previous load time,
if there is new one, reload!
serverengine
config cash
new config
Auto restart
live restart
socket manager
signal handler
log rotation
serverengine advantages
Socket Manager
worker
Socket
Manager
client
Socket
Manager
server
Server
26
①socket listen request②find or create listening socket
③share the socket FD(unix)/
duplicated socket info(windows)
UDS(unix)/
TCP(windows)
④get socket and accept in worker
how to use Socket Manager
worker
Socket
Manager
client
Socket
Manager
server
Server
27
#generate path for UDS/TCP for server connection
socket_manager_path =
ServerEngine::SocketManager::Server.generate_path
#open socket manager server
socket_manager_server =
ServerEngine::SocketManager::Server.open(socket_manager_path)
In server
worker
Socket
Manager
client
Socket
Manager
server
Server
28
#get socket manager client from socket manager path
socket_manager =
ServerEngine::SocketManager::Client.new(socket_manager_path)
#get listening socket from socket manager
lsock = socket_manager.listen_tcp(bind, port)
In worker
how to use Socket Manager
What’s the merit of Socket Manager?
worker
worker
worker
Socket
Manager
client
Socket
Manager
client
Socket
Manager
client
Socket
Manager
server
super
visor
Server
29
we can use multicore easily in future
easy to use multicore power fully
30
with SocketManagerwith in_multiprocess plugin
<source>
type multiprocess
<process>
cmdline -c /etc/td-agent/td-agent-child1.conf
</process>
<process>
cmdline -c /etc/td-agent/td-agent-child2.conf
</process>
</source>
#/etc/td-agent/td-agent-child1.conf
<source>
type forward
port 24224
</source>
#/etc/td-agent/td-agent-child2.conf
<source>
type forward
port 24225
</source>
<source>
type forward
port 24224
</source>
setting when using 2 core
Auto restart
live restart
socket manager
signal handler
log rotation
serverengine advantages
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
USR1
send USR1
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
USR1
USR1
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
QUIT
USR1
send QUIT
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
USR1
QUIT
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
USR1
QUIT
run!
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
QUIT
Queue based signal handling
When user sent USR1 and QUIT…
signal handler thread
user
QUIT run!
Auto restart
live restart
socket manager
signal handler
log rotation
serverengine advantages
support new features
(These are already ported to ruby core.)
・multiprocess aware log rotation
・reopening of log file
・'trace' level, which is lower level than ‘debug'
ServerEngine.create(MyServer, MyWorker, {
log: 'myserver.log',
log_level: 'debug',
log_rotate_age: 5,
log_rotate_size: 1*1024*1024,
})
summary
windows
・signal → rpc handler
・no socket FD and UDS
・fork based → spawn based
・live & auto restart
・multicore with socket manager
・sophisticated signal handler
・easier log rotation
Thank you!
appendix
unix→fork based damon
windows→spawn based damon
damonize
fluentd
server
engine
①set windows_daemon_cmdline
in configuration
②run windows_daemon_cmdline
when damonize
③windows_daemon_cmdline
runs daemon.rb
④run_server with
servermodule and workermodule

Contenu connexe

Tendances

Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
mohamedmoharam
 
OpenNebula and SaltStack - OpenNebulaConf 2013
OpenNebula and SaltStack - OpenNebulaConf 2013OpenNebula and SaltStack - OpenNebulaConf 2013
OpenNebula and SaltStack - OpenNebulaConf 2013
databus.pro
 

Tendances (20)

Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Fluentd v1 and Roadmap
Fluentd v1 and RoadmapFluentd v1 and Roadmap
Fluentd v1 and Roadmap
 
Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014
 
Fluentd v1 and future at techtalk
Fluentd v1 and future at techtalkFluentd v1 and future at techtalk
Fluentd v1 and future at techtalk
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
 
Composer | PHP Dependency Manager
Composer | PHP Dependency ManagerComposer | PHP Dependency Manager
Composer | PHP Dependency Manager
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
 
Ansible automation tool with modules
Ansible automation tool with modulesAnsible automation tool with modules
Ansible automation tool with modules
 
Implement server push in flask framework
Implement server push in flask frameworkImplement server push in flask framework
Implement server push in flask framework
 
ruby + websocket + haproxy
ruby + websocket + haproxyruby + websocket + haproxy
ruby + websocket + haproxy
 
A user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management toolsA user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management tools
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
 
Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
 
Ruby eventmachine pres at rubybdx
Ruby eventmachine pres at rubybdxRuby eventmachine pres at rubybdx
Ruby eventmachine pres at rubybdx
 
Puppet control-repo 
to the next level
Puppet control-repo 
to the next levelPuppet control-repo 
to the next level
Puppet control-repo 
to the next level
 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about Postman
 
openATTIC using grafana and prometheus
openATTIC using  grafana and prometheusopenATTIC using  grafana and prometheus
openATTIC using grafana and prometheus
 
Tp install anything
Tp install anythingTp install anything
Tp install anything
 
OpenNebula and SaltStack - OpenNebulaConf 2013
OpenNebula and SaltStack - OpenNebulaConf 2013OpenNebula and SaltStack - OpenNebulaConf 2013
OpenNebula and SaltStack - OpenNebulaConf 2013
 

Similaire à Fluentd Meetup 2016 - ServerEngine Integration & Windows support

Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docxRunning Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
joellemurphey
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Wesley Beary
 
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docxRunning Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
cowinhelen
 
Presentation iv implementasi 802x eap tls peap mscha pv2
Presentation iv implementasi  802x eap tls peap mscha pv2Presentation iv implementasi  802x eap tls peap mscha pv2
Presentation iv implementasi 802x eap tls peap mscha pv2
Hell19
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Gosuke Miyashita
 

Similaire à Fluentd Meetup 2016 - ServerEngine Integration & Windows support (20)

IMPACT/myGrid Hackathon - Taverna Server as a Portal
IMPACT/myGrid Hackathon - Taverna Server as a PortalIMPACT/myGrid Hackathon - Taverna Server as a Portal
IMPACT/myGrid Hackathon - Taverna Server as a Portal
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
Servlets lecture1
Servlets lecture1Servlets lecture1
Servlets lecture1
 
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
 
Ruby Driver Explained: DataStax Webinar May 5th 2015
Ruby Driver Explained: DataStax Webinar May 5th 2015Ruby Driver Explained: DataStax Webinar May 5th 2015
Ruby Driver Explained: DataStax Webinar May 5th 2015
 
RubyKaigi 2014: ServerEngine
RubyKaigi 2014: ServerEngineRubyKaigi 2014: ServerEngine
RubyKaigi 2014: ServerEngine
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docxRunning Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
Running Head CLIENT SERVER AUTHENTICATIONHANDLING CONCURRENT CL.docx
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
NetScaler Web2.0 Push Technology Overview
NetScaler Web2.0 Push Technology OverviewNetScaler Web2.0 Push Technology Overview
NetScaler Web2.0 Push Technology Overview
 
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
Apache MXNet Distributed Training Explained In Depth by Viacheslav Kovalevsky...
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
 
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docxRunning Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
 
Presentation iv implementasi 802x eap tls peap mscha pv2
Presentation iv implementasi  802x eap tls peap mscha pv2Presentation iv implementasi  802x eap tls peap mscha pv2
Presentation iv implementasi 802x eap tls peap mscha pv2
 
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.jsEWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
 
Service Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and KubernetesService Discovery using etcd, Consul and Kubernetes
Service Discovery using etcd, Consul and Kubernetes
 
Monitoring MySQL with Prometheus and Grafana
Monitoring MySQL with Prometheus and GrafanaMonitoring MySQL with Prometheus and Grafana
Monitoring MySQL with Prometheus and Grafana
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Fluentd Meetup 2016 - ServerEngine Integration & Windows support

  • 1. ServerEngine Integration & Windows support Ritta Narita Fluentd Meetup 2016
  • 2. About me. Ritta Narita joined Treasure Data after internship in 2015 2 @naritta @narittan
  • 4. What’s ServerEngine? A framework to implement robust multiprocess servers like Unicorn worker worker worker super visor Server Dynamic reconfig
 live restart Heartbeat via pipe auto restart multi process/thread
  • 5. how to use ServerEngine worker super visor Server module MyServer def before_run @sock = TCPServer.new( config[:bind], config[:port]) end attr_reader :sock end module MyWorker def run c = server.sock.accept c.write "Awesome work!" end def stop c.close end end 1. write server module and worker module
  • 6. how to use ServerEngine worker super visor Server se = ServerEngine.create(MyServer, MyWorker, { daemonize: true, log: 'myserver.log', pid_path: 'myserver.pid', worker_type: 'process', workers: 4, bind: '0.0.0.0', port: 9071, }) se.run 2. write configuration and run
  • 7. module MyWorker def spawn(process_manager) process_manager.spawn(env, config[:spawn_cmd]) end end ServerEngine.create(MyServer, MyWorker, { worker_type:‘spawn’, spawn_cmd: cmd }) ServerEngine.create(MyServer, MyWorker, { worker_type:‘thread' }) workerServer workerServer workerServer spawn thread processServerEngine.create(MyServer, MyWorker, { worker_type:‘process' }) worker type
  • 8. What’s the advantages for integrating serverengine into fluentd?
  • 9. serverengine advantages Auto restart live restart socket manager signal handler log rotation
  • 10. Auto restart live restart socket manager signal handler log rotation serverengine advantages
  • 11. if worker died unexpectedly… worker worker super visor Server worker
  • 12. if worker died unexpectedly… worker worker worker super visor Server
  • 13. if worker died unexpectedly… worker worker super visor Server It’s detected by heartbeat and server launch worker again. worker
  • 14.
  • 15.
  • 16. Auto restart live restart socket manager signal handler log rotation serverengine advantages
  • 18. super visor Server worker tcp kill the worker, leaving server’s condition live restart
  • 19. worker super visor Server worker tcp start new worker and read config again live restart
  • 20. worker super visor Server worker tcp tcp share the TCP with living zero downtime live restart
  • 21.
  • 22.
  • 23. Signal and RPC server api/config.reloadlive restart/config reload HUP /api/processes .interruptWorkers INT /api/processes .killWorkers /api/plugins. flushBuffers system config reload USR2 TERM USR1flush buffers shutdown
  • 24. worker super visor Server you can reload system config without restart system config reload send USR2 check mtime and previous load time, if there is new one, reload! serverengine config cash new config
  • 25. Auto restart live restart socket manager signal handler log rotation serverengine advantages
  • 26. Socket Manager worker Socket Manager client Socket Manager server Server 26 ①socket listen request②find or create listening socket ③share the socket FD(unix)/ duplicated socket info(windows) UDS(unix)/ TCP(windows) ④get socket and accept in worker
  • 27. how to use Socket Manager worker Socket Manager client Socket Manager server Server 27 #generate path for UDS/TCP for server connection socket_manager_path = ServerEngine::SocketManager::Server.generate_path #open socket manager server socket_manager_server = ServerEngine::SocketManager::Server.open(socket_manager_path) In server
  • 28. worker Socket Manager client Socket Manager server Server 28 #get socket manager client from socket manager path socket_manager = ServerEngine::SocketManager::Client.new(socket_manager_path) #get listening socket from socket manager lsock = socket_manager.listen_tcp(bind, port) In worker how to use Socket Manager
  • 29. What’s the merit of Socket Manager? worker worker worker Socket Manager client Socket Manager client Socket Manager client Socket Manager server super visor Server 29 we can use multicore easily in future
  • 30. easy to use multicore power fully 30 with SocketManagerwith in_multiprocess plugin <source> type multiprocess <process> cmdline -c /etc/td-agent/td-agent-child1.conf </process> <process> cmdline -c /etc/td-agent/td-agent-child2.conf </process> </source> #/etc/td-agent/td-agent-child1.conf <source> type forward port 24224 </source> #/etc/td-agent/td-agent-child2.conf <source> type forward port 24225 </source> <source> type forward port 24224 </source> setting when using 2 core
  • 31.
  • 32.
  • 33. Auto restart live restart socket manager signal handler log rotation serverengine advantages
  • 34. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user USR1 send USR1
  • 35. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user USR1 USR1
  • 36. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user QUIT USR1 send QUIT
  • 37. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user USR1 QUIT
  • 38. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user USR1 QUIT run!
  • 39. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user QUIT
  • 40. Queue based signal handling When user sent USR1 and QUIT… signal handler thread user QUIT run!
  • 41. Auto restart live restart socket manager signal handler log rotation serverengine advantages
  • 42. support new features (These are already ported to ruby core.) ・multiprocess aware log rotation ・reopening of log file ・'trace' level, which is lower level than ‘debug' ServerEngine.create(MyServer, MyWorker, { log: 'myserver.log', log_level: 'debug', log_rotate_age: 5, log_rotate_size: 1*1024*1024, })
  • 43. summary windows ・signal → rpc handler ・no socket FD and UDS ・fork based → spawn based ・live & auto restart ・multicore with socket manager ・sophisticated signal handler ・easier log rotation
  • 46. unix→fork based damon windows→spawn based damon damonize fluentd server engine ①set windows_daemon_cmdline in configuration ②run windows_daemon_cmdline when damonize ③windows_daemon_cmdline runs daemon.rb ④run_server with servermodule and workermodule