Капістрано Та СістемД
Олександр Сімонов
CEO Amoniac OU
RubyConfLT 2017
Capistrano && SystemD
Oleksandr Simonov
CEO Amoniac OU
RubyConfLT 2017
cat /dev/about/me
Software Developer
System Administrator
Engineer
Founder
Team Leader
Speaker
Application Server
4 CPUs / 48Gb RAM
Application Server Inside
PostgreSQL 9.5
Ruby 2.3.3
2 x Rails 4.2 Applications
Puma Cluster 3x32
Sidekiq 3x25
Memory Usage After Boot
PostgreSQL - 500Mb
Puma Cluster - 120Mb
Sidekiq - 100Mb
Total: 500Mb DB + 440Mb Rails App
Memory Usage After One Week
PostgreSQL - 550Mb
Puma Cluster - 2Gb
Sidekiq - 1Gb
Total: 550Mb DB + 6GB Rails App
Memory Usage After One Month
PostgreSQL - 570Mb
Puma Cluster - 5Gb
Sidekiq - 2,5Gb
Total: 570Mb DB + 15GB Rails App
CPU Usage
4 CPUs
5 Nginx processes (master + 4 workers)
8 Puma processes (master + 3 workers )
2 Sidekiq processes
Max 192 PostgreSQL processes (fork on every connection)
Puma
PostgreSQL
Sidekiq
Nginx
IO Usage
PostgreSQL - multiple DB files, log files
Nginx - log files, requests cache, static files, file uploads
Rails - log files, cache files, file uploads, third party services
DiskPostgreSQL
Nginx
Rails
Rails
WHAT TO DO?!
JAIL
nice/ionice/renice
FreeBSD Jail
Solaris Zones
Linux Control Groups
Linux Control Groups
CPU Time
System memory
Disk bandwidth
Network bandwidth
Linux Control Groups
CPU Time - max 20% of time
System memory - 1GB max
Disk bandwidth - 5Mb/sec
Network bandwidth - 2Mb/sec
SystemD
system and service manager
event logger
user session manager
network interfaces manager
device manager
boot manager
systemd + cgroups
Process supervising
Resource management
Dependency management
Logs management
Make a reality
Make a reality
Read about SystemD
Make a reality
Read about SystemD
Read about CGroups
Make a reality
Read about SystemD
Read about CGroups
Create service file
Make a reality
Read about SystemD
Read about CGroups
Create service file
SSH to server and setup it
Make a reality
Read about SystemD
Read about CGroups
Create service file
SSH to server and setup it
SSH to all your servers and do the same
Make a reality
Read about SystemD
Read about CGroups
Create service file
SSH to server and setup it
SSH to all your servers and do the same
PROFIT!
WE NEED AUTOMATE IT!
capistrano-systemd-core
Github: amoniacou/capistrano-systemd-core
capistrano-systemd-core
Simple configuration
Only 1 line setup for each server
No need in SUDO
Support any command
CPU, Memory and IO limitations
Puma, Unicorn, Sidekiq and Resque special support in the future
Simple configuration
set :systemd_services, {
puma: {
cmd: 'puma -p 3000',
cpu_quota: 70,
memory_max: '1G'
},
sidekiq: {
cmd: 'sidekiq',
cpu_quota: 30,
memory_max: '512M'
}
}
Only 1 line setup on server
# loginctl enable-linger username
Supported Limitations
CPUQuota
MemoryMax
IOWeight
Slice
More in the future….
Questions
GitHub: @simonoff
Twitter: @ceo_simonov
FB: @ceosimonov
Website: https://amoniac.eu

Capistrano && SystemD