Optimized multi-threaded JSON generation
When the output of a JSON REST resource is very large (e.g. multiple megabytes), the serialization time can increase to several seconds or even minutes. Structr can be instructed to use multiple threads for JSON generation of a single document, instead of the default single-threaded method.
Multi-threaded JSON generation can be enabled per request using the request parameter
Using this optimization technique introduces the following drawbacks and should be used with caution:
- Structr uses multiple threads and needs to open multiple independent transactions to the database, so actuality and consistency can not be guaranteed when there are lots of changes to the underlying data while the JSON document is created.
- If the creation of a JSON document causes write operations to the database, the possibilty of deadlocks (i.e. nodes that wait for each other’s write operations to finish) rises.
Creating large JSON documents is not recommended, an application should instead fetch smaller parts of the graph independently in separate calls - if possible.
- The Structr Knowledge Graph
- About Structr
- Getting Started
- Installation and Setup
- Working with Structr
- Advanced Topics