Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix the memory issue in WSGI middleware #2450

Closed
wants to merge 3 commits into from

Conversation

peterzaccha
Copy link

Summary

This PR attempts to fix the WSGIMiddleware, which has a serious memory consumption issue when handling large request and response sizes by:

  • Limiting memory usage by reducing the max buffer size in create_memory_object_stream from math.inf to zero.
  • Introducing WsgiRequestBody class for incremental handling of the request body, replacing the previous byte array loading approach.

The implementation for WSGIMiddleware was

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Member

Kludex commented Jan 30, 2024

The middleware is deprecated. Use the a2wsgi package instead.

@Kludex Kludex closed this Jan 30, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants