annotate Sphinx/source/faq/scalability.rst @ 1004:17bf6fafb884

added links to uclouvain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Dec 2023 08:12:21 +0100
parents 6b959b4823aa
children a3436ae3709c
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
984
46e2941b57dd replace link to google users group by link to discourse
Alain Mazy <am@osimis.io>
parents: 963
diff changeset
22 on the `Orthanc Users discussion forum
46e2941b57dd replace link to google users group by link to discourse
Alain Mazy <am@osimis.io>
parents: 963
diff changeset
23 <https://discourse.orthanc-server.org>`__ discussion
317
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
1000
2e103fb1fa11 Orthanc 1.12.2
Alain Mazy <am@osimis.io>
parents: 991
diff changeset
57 * Make sure to use the latest release of Orthanc (1.12.2 at the time of
721
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 719
diff changeset
58 writing) running on a GNU/Linux distribution.
186
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
935
49b863e47c39 PostgreSQL 5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 933
diff changeset
61 <postgresql>` to store the database index (5.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
1004
17bf6fafb884 added links to uclouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
66 case. Note that all `pre-compiled binaries
17bf6fafb884 added links to uclouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
67 <https://orthanc.uclouvain.be/downloads/index.html>`__ provided by
17bf6fafb884 added links to uclouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
68 the Orthanc project are correctly configured in that respect, except
17bf6fafb884 added links to uclouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1002
diff changeset
69 if they are explicitly tagged as "debug".
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
70
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 * 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
72 make sure that the filesystem is properly backed up, and that
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 technologies such as RAID are enabled. Make sure that the option
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 ``EnableStorage`` of the PostgreSQL plugins is set to ``false``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 * Obviously, the PostgreSQL database should be stored on a high-speed
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 drive (SSD). This is less important for the storage area.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
315
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
79 * It may be useful to store the PostgreSQL database on another drive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
80 than the storage area. This should improve the use of the available
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
81 bandwidth to the disks.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
82
831
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
83 * If your Orthanc instance is performing a lot of IO requests in parallel
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
84 e.g because many clients are reading/writing DICOM files at the same
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
85 time, you should consider using an :ref:`object storage <object-storage>`
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
86 plugin to store your files.
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
87
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 * The :ref:`Orthanc configuration file <configuration>` should have
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 the following values for performance-related options (but make sure
189
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
90 to understand their implications):
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 * ``StorageCompression = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 * ``LimitFindResults = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 * ``LimitFindInstances = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 * ``KeepAlive = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 * ``TcpNoDelay = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 * ``StorageAccessOnFind = Never``
663
fcb215df05cb savejobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 646
diff changeset
98 * Consider adding ``SaveJobs = false``
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
643
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: By default, the
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
101 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
102 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
103 ``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
104 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
105 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
106
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
107 * 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
108 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
109 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
110 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
111 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
112 with features such as DICOMweb or viewers.
837
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
113
839
c29ac12e3160 Orthanc-1.11.0
Alain Mazy <am@osimis.io>
parents: 837
diff changeset
114 * From Orthanc 1.11.0: you have the ability to add
837
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
115 more :ref:`main DICOM tags <main-dicom-tags>` in the Orthanc Index
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
116 to speed up C-Find, ``tools/find``, DICOMWeb QIDO-RS, WADO-RS and
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
117 especially WADO-RS Retrieve Metadata.
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
118
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 * Make sure to carefully :ref:`read the logs <log>` in ``--verbose``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 mode, especially at the startup of Orthanc. The logs may contain
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 very important information regarding performance.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
123 * Make sure to read guides about the `tuning of PostgreSQL
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 <https://wiki.postgresql.org/wiki/Performance_Optimization>`__.
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
125
620
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
126 * Make sure to enable the `Autovacuum Daemon
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
127 <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
128 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
129 the PostgreSQL database in order to `reclaim the storage space
532
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
130 <https://www.postgresql.org/docs/current/sql-vacuum.html>`__ that is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
131 occupied by rows that have been deleted from the database (e.g. in a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
132 cron job).
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
133
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
134 * You might also be interested in checking the options related to
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
135 :ref:`security <security>`.
309
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
136
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
137 * Consider using filesystems that are known to achieve high
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
138 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
139 `Btrfs <https://en.wikipedia.org/wiki/Btrfs>`__ on GNU/Linux
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
140 distributions.
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
141
746
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
142 * If you need to grow the storage area as more space becomes needed,
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
143 you can consider the following solutions:
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
144
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
145 - Move the storage area to another disk partition, and update the
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
146 ``StorageDirectory`` :ref:`configuration option <configuration>`
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
147 accordingly.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
148 - :ref:`Replicate <replication>` your current instance of Orthanc
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
149 onto another instance of Orthanc with a larger storage area.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
150 - On GNU/Linux distributions, check out `LVM (Logical Volume Manager)
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
151 <https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)>`__.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
152 - On Microsoft Windows, check out the so-called "`Storage Spaces
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
153 <https://docs.microsoft.com/en-us/windows-server/storage/storage-spaces/overview>`__".
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
154 - Another approach is to use `MinIO <https://docs.min.io/>`__ in
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
155 distributed mode in conjunction with the :ref:`AWS S3 plugin
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
156 <minio>` for Orthanc.
318
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
157
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
158 * 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
159 consider setting configuration option ``StudiesMetadata`` to
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
160 ``MainDicomTags``.
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
161
631
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
162 * 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
163 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
164 minimal, Osimis has observed an impact on performance.
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
165
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
166
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
167 .. _scalability-memory:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
168
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
169 Controlling memory usage
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
170 ------------------------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
171
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
172 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
173 <https://valgrind.org/>`__.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
174
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
175 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
176 consumption
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
177 <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
178 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
179 upload multiple large DICOM files using the REST API.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
180
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
181 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
182 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
183 arenas <https://sourceware.org/glibc/wiki/MallocInternals>`__ are
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
184 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
185 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
186 Orthanc (default value of the ``HttpThreadsCount`` option) allocates
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
187 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
188 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
189 properly free all the buffers.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
190
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
191 .. highlight:: bash
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
192
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
193 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
194 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
195 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
196 environment variable ``MALLOC_ARENA_MAX``. For instance, the following
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
197 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
198 threads in Orthanc::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
199
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
200 $ MALLOC_ARENA_MAX=1 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
201
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
202 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
203 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
204 use 5 arenas::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
205
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
206 $ MALLOC_ARENA_MAX=5 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
207
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
208 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
209 options available as environment variables that could also reduce
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
210 memory consumption (for instance, ``MALLOC_MMAP_THRESHOLD_`` would
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
211 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
212 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
213 of ``mallopt()`` for more information.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
214
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
215 **Status:**
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
216
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
217 * 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
218 automatically sets ``MALLOC_MMAP_THRESHOLD_`` (defaults to ``5``)
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
219 during the startup of Orthanc.
623
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
220
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
221 * 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
222 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
223 release 1.6.1** (cf. `changeset
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
224 <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
225
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
226 * The ``osimis/orthanc`` images automatically set
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
227 ``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
228
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
229
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
230 .. _scalability-limitations:
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
231
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
232 Known limitations
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
233 -----------------
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
234
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
235 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
236 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
237
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
238 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
239 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
240 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
241 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
242 concurrent access to the DB.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
243
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
244 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
245 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
246 presented in this `sample
962
5df222ddd7d1 fix links to setup-samples
Alain Mazy <am@osimis.io>
parents: 947
diff changeset
247 <https://github.com/orthanc-server/orthanc-setup-samples/tree/master/docker/multiple-orthancs-on-same-db/>`__.
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
248 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
249 "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
250 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
251 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
252 conflicts between several instances of Orthanc that would
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
253 simultaneously write to the database.
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 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
256 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
257 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
258 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
259 ``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
260 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
261 also modify the database).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
262
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
263 Some issues reported in our bug tracker are related this limitation:
991
1316bc62b5d5 migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 984
diff changeset
264 `issue 83 <https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=83>`__,
1316bc62b5d5 migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 984
diff changeset
265 `issue 121 <https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=121>`__,
1316bc62b5d5 migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 984
diff changeset
266 `issue 151 <https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=151>`__.
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
267
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
268 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
269 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
270 rewritten.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
271
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 .. _multiple-writers:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
274
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
275 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
276 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
277
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
278 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
279 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
280 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
281 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
282 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
283 transactions to the database.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
284
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
285 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
286 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
287 concurrency. Read-only database transactions are also distinguished
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
288 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
289 further optimize the patterns of access.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
290
646
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
291 Summarizing, the **multiple readers/writers** is now possible. Here is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
292 a drawing representing a possible deployment with 4 Orthanc servers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
293 all sharing the same DICOM images, with some servers handling multiple
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
294 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
295
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
296 .. image:: ../images/2021-04-22-MultipleWriters.png
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
297 :align: center
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
298 :width: 500px
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
299
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
300 Care must be taken to the following aspects:
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
301
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
302 * 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
303 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
304 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
305 not** support multiple writers.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
306
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
307 * 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
308 transactions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
309 <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
310 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
311 same time (cf. ``ErrorCode_DatabaseCannotSerialize`` in the source
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
312 code of Orthanc). Orthanc will **automatically replay such
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
313 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
314 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
315 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
316 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
317 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
318 of concurrent transactions).
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
319
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
320 * 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
321 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
322 a :ref:`revision mechanism <revisions>` to prevent concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
323 updates.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
324
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
325 * Thanks to this support of concurrent accesses, it is possible to put
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
326 a **load balancer** on the top of the REST API of Orthanc. All the
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
327 DICOM resources (patients, studies, series and instances) are indeed
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
328 shared by all the instances of Orthanc connected to the same
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
329 underlying database. As an application, this might be of great help
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
330 if multiple viewers must connect to Orthanc. In `Kubernetes
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
331 <https://kubernetes.io/>`__, concurrent accesses also make it
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
332 possible to manage a set of replicas of Orthanc (e.g. as `deployment
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
333 <https://kubernetes.io/docs/concepts/workloads/controllers/deployment/>`__).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
334
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
335 There are however some caveats if using a load balancer or
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
336 Kubernetes replicas, notably:
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
337
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
338 - Each Orthanc instance maintains its own list of jobs. Therefore,
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
339 the ``/jobs`` route will return only the jobs of the responding
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
340 Orthanc.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
341
1002
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
342 - Similarly, each Orthanc instance maintains its own :ref:`status
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
343 for the resources it has received <stable-resources>`. Thus, the
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
344 ``IsStable`` information is local to each Orthanc instance.
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
345
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
346 - The ``/modalities`` or the ``/peers`` are also private to each
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
347 instance of Orthanc in the cluster, as soon as the respective
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
348 options ``DicomModalitiesInDatabase`` and
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
349 ``OrthancPeersInDatabase`` are set to ``true``.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
350
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
351 If you need to use such primitives in your application, you have
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
352 three possibilities: (1) Introduce a distinguished Orthanc server
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
353 that is responsible to take care of all the jobs (including
1002
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
354 modalities and peers) and/or to receive all the DICOM instances, (2)
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
355 create an :ref:`Orthanc plugin <plugins>` (e.g. using :ref:`Python
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
356 <python-plugin>` or :ref:`Java <java-plugin>`) that queries all the
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
357 Orthanc in the cluster and that aggregates all of their answers,
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
358 or (3) do the same using a higher-level framework (such as Node.js).
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
359
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
360
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
361 Latency
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
362 ^^^^^^^
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
363
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
364 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
365 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
366 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
367 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
368 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
369 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
370 is expected to have correct performances.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
371
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
372 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
373 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
374 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
375 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
376 aggregate even more SQL requests.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
377
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
378 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
379 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
380 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
381 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
382 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
383 concluded before starting another one. Having multiple connections
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
384 makes the latency problem much less important.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
385
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
386
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
387 Slow deletions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
388 ^^^^^^^^^^^^^^
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
389
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
390 Deleting large studies can take much time, because removing a large
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
391 number of files from a filesystem can be an expensive operation (which
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
392 might sound counter-intuitive). This is especially true with HDD
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
393 drives, that can be much slower than SSD (`an user has reported
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
394 <https://groups.google.com/g/orthanc-users/c/1lga0oFCHN4/m/jF1inrc4AgAJ>`__
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
395 a 20 times speedup by switching from HDD to SSD).
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
396
861
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
397 If switching from HDD to SDD is not applicable, you may also use
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
398 the :ref:`Delayed Deletion plugin <delayed-deletion-plugin>` .
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
399 The plugin would maintains a queue of files to be removed. The actual
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
400 deletion from the filesystem is done asynchronously in a
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
401 separate thread.