Closed vtlkvl closed 1 year ago
@vtlkvl i think this PR lgtm, could you sign the CLA so I can proceed to merge? Thanks!
I pushed additional minor change to check for the result type to be dict. It should be read to go.
Merged! @vtlkvl Again thank you for the investigation and the fix!
Released in 0.35
Sweet!
Memory leak is reported in https://github.com/Kong/kong-python-pdk/issues/120.
There are two scenarios when message queues are not deleted that leads to the memory leak:
ret
message inPluginServer.handle_event
and no further messaging is expected, but we still store the message queue in the dictionary which is never deleted afterwards.kong.response.exit
orkong.response.error
,PluginServer._step
will be called with the JSON payload and method name being called rather than with theret
message. After this no further messaging is expected, but we don't delete the message queue that leads to the memory leakFor testing I used steps described in https://github.com/vtlkvl/kong-python-pluginserver-memory-leak and ran
siege
with concurrency 50 and duration 30 seconds.Results before the fix:
Results after the fix:
After the fix the count of
collections.deque
,queue.Queue
andthreading.Condition
remains stable and low. No memory leak is observed. For what it is worth, the request throughout has increased by ~10% based on siege results.