Skip to content

App restart delay (5s) / shutdown-timeout should be shortcutted if daemon process is idle (no requests) #923

@QuadrupleA

Description

@QuadrupleA

I've been digging into some slow restart problems on one of our VMs using bpftrace (sometimes 60+ seconds for a full httpd restart). Along the way I noticed a possible performance issue (or at least possible improvement) with the restart of individual WSGI apps / daemon processes.

The shutdown-timeout option (default 5 seconds) on WSGIDaemonProcess seems to be a mandatory wait, rather than "wait up to N seconds until idle". The behavior is roughly:

  1. touch the WSGI script (application.py)
  2. make a request to the app, triggering a daemon process restart; apache holds connection open and browser starts waiting for response
  3. from tracing, I see the old daemon process PID makes a 5 second nanosleep() syscall during which nothing happens (the app is idle and receiving no requests besides the pending test request)
  4. the nanosleep period ends, the old daemon process shuts down, and the new one is cloned and started up
  5. the new daemon process handles the request

It would be nice, during #3, if the daemon process is idle (no requests), to restart immediately, rather than requiring waiting the full shutdown-timeout each time. It would be less delays for users when apps need a quick patch, less chance of secondary bugs and issues happening due to the delayed requests, etc.

Happy to share more details if it sounds like something particular to our Apache configuration.

Side note, thanks to Graham for his longtime, dedicated support (both documentation / assistance, and coding) on this excellent module. It's been sitting reliably at the foundation of our applications for years, and when I've needed it I've nearly always found the documentation, expert StackOverflow answer from him, etc. to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions