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.

Graph-Browser

About this article
Last change 2018-10-11
Topics REST