You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

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.

Usage
Multi-threaded JSON generation can be enabled per request using the request parameter parallelizeJsonOutput.

Example

GET /Projects?parallelizeJsonOutput

Known problems
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.

Note
Creating large JSON documents is not recommended, an application should instead fetch smaller parts of the graph independently in separate calls - if possible.

Search results for "Optimized multi-threaded JSON generation"

We could not find anything matching "Optimized multi-threaded JSON generation" in our documentation. Please rephrase your search.

You can also ask your questions in the Structr Google Group or create a free account in the Structr Support Portal.
Click here to send feedback to the Structr team.