Skip to content

Different behaviour between sync and gthread workers with preload=True #3384

Description

@mihalikv

Gunicorn version: 23.0.0 also 20.1.0

Problem:

I have application in Django 4.2, we are running this application in production with following settings:

  • workers = cpu.count + 1
  • threads = 8
  • preload=True

When I tried to change these configuration my best result(RPS, request duration) was with these settings:

  • workers = cpu.count + 1
  • threads = 1
  • preload = False

Hovewer I would like to use preload=True but problem is that application start crashing when sync workers are user together with preload=True.

Settings Does it work ?
workers=8 threads=1 preload=False Yes
workers=8 threads=2 preload=False Yes
workers=8 threads=2 preload=True Yes (something like this is currenly used in production)
workers=8 threads=1 preload=True No

Exception:

Basically exception are different, but generally there is something wrong with DB/cache and memory sharing, I guess.

Image

Expectations:

I understand that my app may have some flaws, and preload might be sharing memory incorrectly, which causes these exceptions.
However, I don't understand why this is not a problem when gthreads are used?

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