annotate Sphinx/source/faq/scalability.rst @ 660:a6e371768a70

dicom-as-json
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Apr 2021 12:41:31 +0200
parents fe7b80fe3caf
children fcb215df05cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _scalability:
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 Scalability of Orthanc
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 ======================
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
6 .. contents::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
7
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
8 Overview
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
9 --------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
10
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 One of the most common question about Orthanc is: *"How many DICOM
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 instances can be stored by Orthanc?"*
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
14 The source code of Orthanc imposes no such hard limit by itself.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
15
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
16 At the time of writing, we know that Orthanc is being used in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
17 production in hospitals with more than 15TB of data, 125,000 studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
18 and around 50 millions of instances (please `get in touch with us
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
19 <https://www.orthanc-server.com/static.php?page=contact>`__ if you can
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
20 share other testimonials). Other users have even reported more than
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
21 28TB of data. Here are links to some testimonials that were published
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
22 on the `Orthanc Users
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
23 <https://groups.google.com/forum/#!forum/orthanc-users>`__ discussion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
24 group: `1
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
25 <https://groups.google.com/d/msg/orthanc-users/-L0D1c2y6rw/KmWnwEijAgAJ>`__,
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
26 `2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
27 <https://groups.google.com/d/msg/orthanc-users/-L0D1c2y6rw/nLXxtYzuCQAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
28 `3
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
29 <https://groups.google.com/d/msg/orthanc-users/s5-XlgA2BEY/ZpYagqBwAAAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
30 `4
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
31 <https://groups.google.com/d/msg/orthanc-users/A4hPaJo439s/NwR6zk9FCgAJ>`__,
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
32 `5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
33 <https://groups.google.com/d/msg/orthanc-users/Z5cLwbVgJc0/SxVzxF7ABgAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
34 `6
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
35 <https://groups.google.com/d/msg/orthanc-users/6tGNOqlUk-Q/vppkAYnFAQAJ>`__...
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
36
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
37 The stress is actually put on the underlying database engine, and on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
38 the storage area (check out :ref:`orthanc-storage`). As explained in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
39 the :ref:`troubleshooting section <troubleshooting>`, the built-in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
40 SQLite database engine should be replaced by an enterprise-ready
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
41 database engine once Orthanc must store several hundreds of thousands
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
42 of DICOM instances (check out the :ref:`postgresql` and
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
43 :ref:`mysql`). It is also true that the performance of Orthanc in the
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
44 presence of large databases has continuously improved over time,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
45 especially when it comes to the speed of :ref:`DICOM C-FIND
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
46 <dicom-find>`.
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
48
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
49 .. _scalability-setup:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
50
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
51 Recommended setup for best performance
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
52 --------------------------------------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
53
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Here is a generic setup that should provide best performance in the
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 presence of large databases:
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
638
b3e75cef601d Orthanc 1.9.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 631
diff changeset
57 * Make sure to use the latest release of Orthanc (1.9.2 at the time of
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 writing).
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 * We suggest to use the latest release of the :ref:`PostgreSQL plugin
640
75ac001a48ac PostgreSQL 4.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 638
diff changeset
61 <postgresql>` to store the database index (4.0 at the time of
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 writing). Make sure that ``EnableIndex`` is set to ``true``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
64 * Make sure that :ref:`run-time debug assertions <troubleshooting>`
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
65 are turned off. A warning will show in the logs if this is not the
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
66 case. Note that all pre-built binaries provided by Osimis are
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
67 correctly configured in that respect.
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
68
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 * We suggest to use the default filesystem storage area. Of course,
190
5444374c4202 faq: Fix typo: "backup" -> "backed up"
Thibault Nélis <tn@osimis.io>
parents: 189
diff changeset
70 make sure that the filesystem is properly backed up, and that
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 technologies such as RAID are enabled. Make sure that the option
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ``EnableStorage`` of the PostgreSQL plugins is set to ``false``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 * Obviously, the PostgreSQL database should be stored on a high-speed
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 drive (SSD). This is less important for the storage area.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
315
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
77 * It may be useful to store the PostgreSQL database on another drive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
78 than the storage area. This should improve the use of the available
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
79 bandwidth to the disks.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
80
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 * The :ref:`Orthanc configuration file <configuration>` should have
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 the following values for performance-related options (but make sure
189
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
83 to understand their implications):
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 * ``StorageCompression = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 * ``LimitFindResults = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 * ``LimitFindInstances = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 * ``KeepAlive = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 * ``TcpNoDelay = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 * ``SaveJobs = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 * ``StorageAccessOnFind = Never``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
93 * Since Orthanc 1.9.2 and PostgreSQL plugins 4.0: By default, the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
94 PostgreSQL index plugin uses 1 single connection to the PostgreSQL
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
95 database. You can have multiple connections by setting the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
96 ``IndexConnectionsCount`` to a higher value (for instance ``5``) in
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
97 the ``PostgreSQL`` section of the configuration file. This will
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
98 improve concurrency. Check out :ref:`the explanation below <multiple-writers>`.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
99
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
100 * Since Orthanc 1.9.2 and PostgreSQL plugins 4.0: If you have an
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
101 hospital-wide VNA deployment, you could consider to deploy multiple
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
102 Orthanc servers sharing the same PostgreSQL database. A typical
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
103 scenario is having one "writer" Orthanc server that handles the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
104 ingesting of DICOM instances, and multiple "reader" Orthanc servers
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
105 with features such as DICOMweb or viewers.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
106
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 * Make sure to carefully :ref:`read the logs <log>` in ``--verbose``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 mode, especially at the startup of Orthanc. The logs may contain
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 very important information regarding performance.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
111 * Make sure to read guides about the `tuning of PostgreSQL
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 <https://wiki.postgresql.org/wiki/Performance_Optimization>`__.
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
113
620
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
114 * Make sure to enable the `Autovacuum Daemon
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
115 <https://www.postgresql.org/docs/current/routine-vacuuming.html>`__
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
116 of PostgreSQL, or to periodically run the ``VACUUM`` SQL command on
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
117 the PostgreSQL database in order to `reclaim the storage space
532
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
118 <https://www.postgresql.org/docs/current/sql-vacuum.html>`__ that is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
119 occupied by rows that have been deleted from the database (e.g. in a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
120 cron job).
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
121
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
122 * You might also be interested in checking the options related to
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
123 :ref:`security <security>`.
309
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
124
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
125 * Consider using filesystems that are known to achieve high
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
126 performance, such as `XFS <https://en.wikipedia.org/wiki/XFS>`__ or
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
127 `Btrfs <https://en.wikipedia.org/wiki/Btrfs>`__ on GNU/Linux
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
128 distributions.
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
129
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
130 * On GNU/Linux distributions, `LVM (Logical Volume Manager)
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
131 <https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)>`__
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
132 can be used to dynamically and easily grow the storage area as more
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
133 space becomes needed.
318
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
134
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
135 * If using the :ref:`DICOMweb server plugin <dicomweb-server-config>`,
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
136 consider setting configuration option ``StudiesMetadata`` to
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
137 ``MainDicomTags``.
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
138
631
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
139 * If using PostgreSQL as a managed cloud service by Microsoft Azure,
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
140 make sure to reduce the verbosity of the logs. If logging is not
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
141 minimal, Osimis has observed an impact on performance.
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
142
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
143
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
144 .. _scalability-memory:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
145
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
146 Controlling memory usage
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
147 ------------------------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
148
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
149 The absence of memory leaks in Orthanc is verified thanks to `valgrind
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
150 <https://valgrind.org/>`__.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
151
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
152 On GNU/Linux systems, you might however `observe a large memory
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
153 consumption
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
154 <https://groups.google.com/d/msg/orthanc-users/qWqxpvCPv8g/47wnYyhOCAAJ>`__
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
155 in the "resident set size" (VmRSS) of the application, notably if you
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
156 upload multiple large DICOM files using the REST API.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
157
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
158 This large memory consumption comes from the fact that the embedded
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
159 HTTP server is heavily multi-threaded, and that many so-called `memory
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
160 arenas <https://sourceware.org/glibc/wiki/MallocInternals>`__ are
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
161 created by the glibc standard library (up to one per thread). As a
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
162 consequence, if each one of the 50 threads in the HTTP server of
392
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
163 Orthanc (default value of the ``HttpThreadsCount`` option) allocates
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
164 at some point, say, 50MB, the total memory usage reported as "VmRSS"
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
165 can grow up to 50 threads x 50MB = 2.5GB, even if the Orthanc threads
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
166 properly free all the buffers.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
167
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
168 .. highlight:: bash
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
169
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
170 A possible solution to reducing this memory usage is to ask glibc to
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
171 limit the number of "memory arenas" that are used by the Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
172 process. On GNU/Linux, this can be controlled by setting the
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
173 environment variable ``MALLOC_ARENA_MAX``. For instance, the following
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
174 bash command-line would use one single arena that is shared by all the
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
175 threads in Orthanc::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
176
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
177 $ MALLOC_ARENA_MAX=1 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
178
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
179 Obviously, this restrictive setting will use minimal memory, but will
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
180 result in contention among the threads. A good compromise might be to
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
181 use 5 arenas::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
182
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
183 $ MALLOC_ARENA_MAX=5 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
184
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
185 Memory allocation on GNU/Linux is a complex topic. There are other
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
186 options available as environment variables that could also reduce
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
187 memory consumption (for instance, ``MALLOC_MMAP_THRESHOLD_`` would
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
188 bypass arenas for large memory blocks such as DICOM files). Check out
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
189 the `manpage <http://man7.org/linux/man-pages/man3/mallopt.3.html>`__
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
190 of ``mallopt()`` for more information.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
191
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
192 **Status:**
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
193
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
194 * Since **Orthanc 1.8.2**, the global configuration ``MallocArenaMax``
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
195 automatically sets ``MALLOC_MMAP_THRESHOLD_`` (defaults to ``5``)
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
196 during the startup of Orthanc.
623
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
197
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
198 * The ``jodogne/orthanc`` and ``jodogne/orthanc-plugins`` Docker
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
199 images automatically set ``MALLOC_ARENA_MAX`` to ``5`` **since
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
200 release 1.6.1** (cf. `changeset
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
201 <https://github.com/jodogne/OrthancDocker/commit/bd7e9f4665ce8dd6892f82a148cabe8ebcf1c7d9>`__).
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
202
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
203 * The ``osimis/orthanc`` images automatically set
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
204 ``MALLOC_ARENA_MAX`` to ``5`` **since release 20.12.2**.
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
205
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
206
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
207 .. _scalability-limitations:
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
208
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
209 Known limitations
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
210 -----------------
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
211
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
212 Exclusive access to the DB in Orthanc <= 1.9.1
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
213 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
214
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
215 Orthanc was originally designed as a mini-DICOM server in 1-to-1
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
216 relation with a SQLite database. Until **Orthanc 1.9.1**, because of
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
217 this original design, the internal code accessing the DB was affected
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
218 by a strong limitation: Inside a single Orthanc process, there was no
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
219 concurrent access to the DB.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
220
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
221 One solution to avoid this limitation was to have multiple Orthanc
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
222 accessing the same DB (works only for MySQL and PostgreSQL) as
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
223 presented in this `sample
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
224 <https://bitbucket.org/osimis/orthanc-setup-samples/src/master/docker/multiple-orthancs-on-same-db/>`__.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
225 However, this solution was only robust if there was **one single
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
226 "writer" Orthanc server** (i.e. only one Orthanc was modifying the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
227 database). Indeed, the core of Orthanc <= 1.9.1 did not support the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
228 replay of database transactions, which is necessary to deal with
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
229 conflicts between several instances of Orthanc that would
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
230 simultaneously write to the database.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
231
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
232 Concretely, in Orthanc <= 1.9.1, when connecting multiple Orthanc to a
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
233 single database by setting ``Lock`` to ``false``, there should only be
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
234 one instance of Orthanc acting as a writer and all the other instances
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
235 of Orthanc acting as readers only. Be careful to set the option
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
236 ``SaveJobs`` to ``false`` in the configuration file of all the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
237 instances of Orthanc acting as readers (otherwise the readers would
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
238 also modify the database).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
239
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
240 Some issues reported in our bug tracker are related this limitation:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
241 `issue 83 <https://bugs.orthanc-server.com/show_bug.cgi?id=83>`__,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
242 `issue 121 <https://bugs.orthanc-server.com/show_bug.cgi?id=121>`__,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
243 `issue 151 <https://bugs.orthanc-server.com/show_bug.cgi?id=151>`__.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
244
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
245 This limitation has disappeared with Orthanc 1.9.2 and
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
246 PostgreSQL/MySQL plugins 4.0, were the database engine was fully
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
247 rewritten.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
248
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
249
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
250 .. _multiple-writers:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
251
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
252 Concurrent accesses to the DB in Orthanc >= 1.9.2
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
254
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
255 In **Orthanc 1.9.2 and PostgreSQL/MySQL plugins 4.0**, the database
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
256 engine of Orthanc was rewritten from scratch to allow multiple
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
257 writers/readers to share the same database. This new feature
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
258 necessitated a full refactoring of the database engine, so as to
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
259 replay transactions in the case of collisions between concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
260 transactions to the database.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
261
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
262 Furthermore, one Orthanc server can also manage several connections to
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
263 PostgreSQL or MySQL, in order to improve performance by adding
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
264 concurrency. Read-only database transactions are also distinguished
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
265 from read-write transactions in order for the database engine to
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
266 further optimize the patterns of access.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
267
646
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
268 Summarizing, the **multiple readers/writers** is now possible. Here is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
269 a drawing representing a possible deployment with 4 Orthanc servers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
270 all sharing the same DICOM images, with some servers handling multiple
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
271 connections to a PostgreSQL database for higher throughput:
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
272
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
273 .. image:: ../images/2021-04-22-MultipleWriters.png
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
274 :align: center
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
275 :width: 500px
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
276
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
277 Care must be taken to the following aspects:
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
278
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
279 * Orthanc 1.9.2 must be combined with a database plugin that supports
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
280 multiple writers. This is the case of the PostgreSQL and MySQL
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
281 plugins with version >= 4.0. The built-in SQLite database **does
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
282 not** support multiple writers.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
283
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
284 * Concurrent access can result in so-called `non-serializable
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
285 transactions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
286 <https://en.wikipedia.org/wiki/Isolation_(database_systems)#Serializable>`__
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
287 if two separate database transactions modify the database at the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
288 same time (cf. ``ErrorCode_DatabaseCannotSerialize`` in the source
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
289 code of Orthanc). Orthanc will **automatically replay such
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
290 transactions** a certain number of times (waiting 100ms more between
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
291 each retry), until the transactions succeed. The plugins provide an
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
292 option to control the maximum number of retries. If the maximum
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
293 number of retries is exceeded, the ``503 Service Unavailable`` HTTP
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
294 error is raised (server overloaded because of unsuccessful retries
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
295 of concurrent transactions).
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
296
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
297 * If a higher-level application **modifies metadata and/or
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
298 attachments** in the presence of multiple writers, Orthanc provides
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
299 a :ref:`revision mechanism <revisions>` to prevent concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
300 updates.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
301
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
302
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
303
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
304 Latency
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
305 ^^^^^^^
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
306
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
307 For some queries to the database, Orthanc performs several small SQL
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
308 requests. For instance, a request to a route like ``/studies/{id}``
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
309 can trigger 6 SQL queries. Given these round-trips between Orthanc and
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
310 the DB server, it's important for the **network latency to be as small
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
311 as possible**. For instance, if your latency is 20ms, a single request
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
312 to ``/studies/{id}`` might take 120ms. Typically, a latency of 1-4 ms
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
313 is expected to have correct performances.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
314
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
315 As a consequence, if deploying Orthanc in a cloud infrastructure, make
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
316 sure that the DB server and Orthanc VMs are located in the **same
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
317 datacenter**. Note that most of the time-consuming queries have
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
318 already been optimized, and that future versions of Orthanc SDK might
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
319 aggregate even more SQL requests.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
320
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
321 Starting with Orthanc 1.9.2, and PostgreSQL/MySQL index plugins 4.0,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
322 Orthanc can also be configured to handle **multiple connections to the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
323 database server** by setting the ``IndexConnectionsCount`` to a value
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
324 greater than ``1``. This allows concurrent accesses to the database,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
325 which avoids to sequentially wait for a database transaction to be
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
326 concluded before starting another one. Having multiple connections
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
327 makes the latency problem much less important.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
328
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
329
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
330 Slow deletions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
331 ^^^^^^^^^^^^^^
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
332
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
333 Deleting large studies can take some time, because removing a large
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
334 number of files from a filesystem can be an expensive operation (which
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
335 might sound counterintuitive).
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
336
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
337 It is possible to create an :ref:`storage area plugin
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
338 <creating-plugins>` that delays the actual deletion from the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
339 filesystem. The plugin would maintain a queue (e.g. as a SQLite
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
340 database) of files to be removed. The actual deletion from the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
341 filesystem would be done asynchronously in a separate thread.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
342
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
343 We are looking for funding from the industry to implement such a
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
344 plugin.