Piotr Jurewicz Yes that's a good way to tackle down "most" of possible sources that can cause a process to die. But of course there might be other. For instance, if you have your rails app in the same instance, it can grow in ram too, so even having sidekiq with low memory usage, the system can enter a "resource starvation" state and the Kernel would kill proceses to safeguard the system state. The way the Kernel chooses this proceses is based in many factors, so there's still chance your sidekiq dies.
What happens if the process dies? you are not using a process manager like upstart, systemd or supervisord.
We have al these scripts to manage sidekiq properly.
commands: 02_create_sidekiq_log_file: command: touch /var/log/sidekiq_worker.logfiles: "/opt/elasticbeanstalk/support/conf/sidekiq_worker.conf": mode: "000755" owner: root group: root content: | description "Elastic Beanstalk Sidekiq Background Worker" # Greatly reduce Ruby memory fragmentation and heap usage # mikeperham.com/2018/04/25/taming-rails-memory-blo… env MALLOC_ARENA_MAX=2 respawn respawn limit 3 30 # TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as # normal exit codes, it just respawns. normal exit 0 TERM # Upstart waits 5 seconds by default to kill a process. Increase timeout to # give sidekiq process enough time to exit. kill timeout 30 script exec /bin/bash <<"EOT" EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir) EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) . $EB_SUPPORT_DIR/envvars . $EB_SCRIPT_DIR/use-app-ruby.sh EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir) cd $EB_APP_DEPLOY_DIR echo "Bundle exec sidekiq worker" exec bundle exec sidekiq -e ${RACK_ENV} \ -C ${EB_APP_DEPLOY_DIR}/config/sidekiq.yml >/var/log/sidekiq_worker.log 2>&1 EOT end scriptfiles: "/etc/init/sidekiq_worker.conf": mode: "120400" content: "/opt/elasticbeanstalk/support/conf/sidekiq_worker.conf" "/etc/init/workers.conf": mode: "000755" owner: root group: root content: | description "Manages the Set of Sidekiq Processes" # Use "sudo stop workers" to stop all Sidekiq instances. # Use "sudo start workers" to start all instances. # Use "sudo restart workers" to restart all instances. # This starts upon bootup and stops on shutdown start on runlevel [2345] stop on runlevel [06] pre-start script sudo start sidekiq_worker end script post-stop script sudo stop sidekiq_worker end script commands: reload_initctl_for_sidekiq: command: "sudo initctl reload-configuration"files: "/tmp/sidekiq_mute.sh": mode: "000755" owner: root group: root content: | #!/bin/bash skwpid=$(initctl status sidekiq_worker | grep /running | awk '{print $NF}') if [ -f skwpid ] then echo "TSTP/quieting sidekiq worker" sudo kill -TSTP skwpid fifiles: "/tmp/sidekiq_restart.sh": mode: "000755" owner: root group: root content: | #!/bin/bash skwpid=$(initctl status sidekiq_worker | grep /running | awk '{print $NF}') if [ -f skwpid ] then echo "TERM/terminating sidekiq worker" sudo kill -TERM skwpid fi echo "STOPPING all sidekiq workers" sudo stop workers echo "STARTING all sidekiq workers" sudo start workersfiles: "/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_restart.sh" "/opt/elasticbeanstalk/hooks/configdeploy/post/50_restart_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_restart.sh" "/opt/elasticbeanstalk/hooks/restartappserver/post/50_restart_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_restart.sh" "/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_mute.sh" "/opt/elasticbeanstalk/hooks/configdeploy/pre/03_mute_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_mute.sh" "/opt/elasticbeanstalk/hooks/restartappserver/pre/03_mute_sidekiq.sh": mode: "120755" owner: root group: root content: "/tmp/sidekiq_mute.sh"