Python updating a global resource pool causes requests to block

Backdrop: Service basics: Django framework, cpu intensive service, start five uwsgi processes

Because the underlying resource of the service is very large (2G), there are multiple versions, and this variable cannot be pickled, it is designed in the form of five processes

The shape of this resource is as follows:

GResource = {'key_1':resource_1, 'key_2':resource_2,'key_3':resource_3}

Each request accesses this global variable GResource. At the same time, GResource is updated by BackgroundScheduler every two minutes

Request time monitoring shows that when the 'GResource' cycle is updated, the request time will be higher than usual, usually 50 to 300ms, or even higher

May I ask why

Back to Top