Skip to content

Performance optimization: indexes have been added to the database and orjson has been implemented to accelerate API, logs and middleware#20

Merged
codewithme-py merged 1 commit intomainfrom
feat/switch-json-serializer-to-orjson
Mar 12, 2026
Merged

Performance optimization: indexes have been added to the database and orjson has been implemented to accelerate API, logs and middleware#20
codewithme-py merged 1 commit intomainfrom
feat/switch-json-serializer-to-orjson

Conversation

@codewithme-py
Copy link
Copy Markdown
Owner

Summary

Comprehensive optimization of system performance: acceleration of work with the database through indexing and transition to ORJSON to reduce the load on the CPU during serialization.

What has changed:

  • Database: Added indexes for all Foreign Keys in order and inventory models, as well as for the field critical for background tasks expires_at. This eliminates Sequential Scan when clearing expired reservations.

  • Serialization: The orjson (Rust) library has been implemented as a standard serializer for FastAPI (ORJSONResponse).

  • Middleware: The work of the idempotency decorator has been optimized - reading and writing the cache in Redis now occurs through orjson, which gives an increase in speed on highly loaded endpoints.

  • Logging: Configured structlog using orjson to render logs in JSON.

… orjson has been implemented to accelerate API, logs and middleware
@codewithme-py codewithme-py merged commit 4bd4cdf into main Mar 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant