annotate Sphinx/source/faq/scalability.rst @ 1113:a588960a72e5 default tip

spelling
author Alain Mazy <am@orthanc.team>
date Mon, 28 Oct 2024 09:23:08 +0100
parents eaf09977e3e9
children
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
1075
d2be251975d1 Orthanc 1.12.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1034
diff changeset
57 * Make sure to use the latest release of Orthanc (1.12.4 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
1034
Alain Mazy <am@osimis.io>
parents: 1023
diff changeset
103 ``IndexConnectionsCount`` to a higher value (for instance ``50`` or one per HTTP thread) in
643
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
1034
Alain Mazy <am@osimis.io>
parents: 1023
diff changeset
114 * Since Orthanc 1.12.3 and PostgreSQL plugins 6.0: You may enable
Alain Mazy <am@osimis.io>
parents: 1023
diff changeset
115 the ``ReadCommitted`` transaction mode to allow multiple threads to
Alain Mazy <am@osimis.io>
parents: 1023
diff changeset
116 write in DB at the same time.
Alain Mazy <am@osimis.io>
parents: 1023
diff changeset
117
839
c29ac12e3160 Orthanc-1.11.0
Alain Mazy <am@osimis.io>
parents: 837
diff changeset
118 * 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
119 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
120 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
121 especially WADO-RS Retrieve Metadata.
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
122
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 * Make sure to carefully :ref:`read the logs <log>` in ``--verbose``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 mode, especially at the startup of Orthanc. The logs may contain
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 very important information regarding performance.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
127 * Make sure to read guides about the `tuning of PostgreSQL
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 <https://wiki.postgresql.org/wiki/Performance_Optimization>`__.
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
129
620
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
130 * Make sure to enable the `Autovacuum Daemon
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
131 <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
132 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
133 the PostgreSQL database in order to `reclaim the storage space
532
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
134 <https://www.postgresql.org/docs/current/sql-vacuum.html>`__ that is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
135 occupied by rows that have been deleted from the database (e.g. in a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
136 cron job).
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
137
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
138 * You might also be interested in checking the options related to
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
139 :ref:`security <security>`.
309
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
140
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
141 * Consider using filesystems that are known to achieve high
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
142 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
143 `Btrfs <https://en.wikipedia.org/wiki/Btrfs>`__ on GNU/Linux
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
144 distributions.
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
145
746
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
146 * 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
147 you can consider the following solutions:
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
148
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
149 - 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
150 ``StorageDirectory`` :ref:`configuration option <configuration>`
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
151 accordingly.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
152 - :ref:`Replicate <replication>` your current instance of Orthanc
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
153 onto another instance of Orthanc with a larger storage area.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
154 - On GNU/Linux distributions, check out `LVM (Logical Volume Manager)
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
155 <https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)>`__.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
156 - On Microsoft Windows, check out the so-called "`Storage Spaces
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
157 <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
158 - 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
159 distributed mode in conjunction with the :ref:`AWS S3 plugin
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
160 <minio>` for Orthanc.
318
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
161
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
162 * 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
163 consider setting configuration option ``StudiesMetadata`` to
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
164 ``MainDicomTags``.
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
165
631
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
166 * 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
167 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
168 minimal, Osimis has observed an impact on performance.
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
169
384
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 .. _scalability-memory:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
172
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
173 Controlling memory usage
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
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
176 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
177 <https://valgrind.org/>`__.
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 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
180 consumption
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
181 <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
182 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
183 upload multiple large DICOM files using the REST API.
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 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
186 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
187 arenas <https://sourceware.org/glibc/wiki/MallocInternals>`__ are
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
188 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
189 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
190 Orthanc (default value of the ``HttpThreadsCount`` option) allocates
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
191 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
192 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
193 properly free all the buffers.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
194
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
195 .. highlight:: bash
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
196
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
197 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
198 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
199 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
200 environment variable ``MALLOC_ARENA_MAX``. For instance, the following
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
201 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
202 threads in Orthanc::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
203
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
204 $ MALLOC_ARENA_MAX=1 ./Orthanc
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 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
207 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
208 use 5 arenas::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
209
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
210 $ MALLOC_ARENA_MAX=5 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
211
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
212 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
213 options available as environment variables that could also reduce
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
214 memory consumption (for instance, ``MALLOC_MMAP_THRESHOLD_`` would
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
215 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
216 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
217 of ``mallopt()`` for more information.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
218
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
219 **Status:**
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 * 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
222 automatically sets ``MALLOC_MMAP_THRESHOLD_`` (defaults to ``5``)
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
223 during the startup of Orthanc.
623
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
224
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
225 * 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
226 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
227 release 1.6.1** (cf. `changeset
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
228 <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
229
1023
5d4701d8fe28 replaced osimis/orthanc by orthancteam/orthanc
Alain Mazy <am@osimis.io>
parents: 1021
diff changeset
230 * The ``orthancteam/orthanc`` images automatically set
623
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
231 ``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
232
438
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 .. _scalability-limitations:
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
235
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
236 Known limitations
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
237 -----------------
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
238
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
239 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
240 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
241
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
242 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
243 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
244 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
245 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
246 concurrent access to the DB.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
247
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
248 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
249 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
250 presented in this `sample
962
5df222ddd7d1 fix links to setup-samples
Alain Mazy <am@osimis.io>
parents: 947
diff changeset
251 <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
252 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
253 "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
254 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
255 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
256 conflicts between several instances of Orthanc that would
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
257 simultaneously write to the database.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
258
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
259 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
260 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
261 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
262 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
263 ``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
264 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
265 also modify the database).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
266
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
267 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
268 `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
269 `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
270 `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
271
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
272 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
273 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
274 rewritten.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
275
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 .. _multiple-writers:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
278
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
279 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
280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
281
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
282 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
283 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
284 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
285 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
286 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
287 transactions to the database.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
288
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
289 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
290 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
291 concurrency. Read-only database transactions are also distinguished
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
292 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
293 further optimize the patterns of access.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
294
646
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
295 Summarizing, the **multiple readers/writers** is now possible. Here is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
296 a drawing representing a possible deployment with 4 Orthanc servers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
297 all sharing the same DICOM images, with some servers handling multiple
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
298 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
299
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
300 .. image:: ../images/2021-04-22-MultipleWriters.png
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
301 :align: center
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
302 :width: 500px
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
303
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
304 Care must be taken to the following aspects:
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
305
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
306 * 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
307 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
308 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
309 not** support multiple writers.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
310
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
311 * 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
312 transactions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
313 <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
314 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
315 same time (cf. ``ErrorCode_DatabaseCannotSerialize`` in the source
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
316 code of Orthanc). Orthanc will **automatically replay such
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
317 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
318 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
319 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
320 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
321 error is raised (server overloaded because of unsuccessful retries
1088
eaf09977e3e9 ReadCommitted
Alain Mazy <am@orthanc.team>
parents: 1075
diff changeset
322 of concurrent transactions). Note that, since version 6.0 of the PostgreSQL
eaf09977e3e9 ReadCommitted
Alain Mazy <am@orthanc.team>
parents: 1075
diff changeset
323 plugin, it is now possible to configure the ``TransactionMode`` to
eaf09977e3e9 ReadCommitted
Alain Mazy <am@orthanc.team>
parents: 1075
diff changeset
324 ``ReadCommitted`` instead of the default ``Serializable`` mode to avoid
eaf09977e3e9 ReadCommitted
Alain Mazy <am@orthanc.team>
parents: 1075
diff changeset
325 most of the transactions collisions. This option is not (yet) available
eaf09977e3e9 ReadCommitted
Alain Mazy <am@orthanc.team>
parents: 1075
diff changeset
326 for the MySQL plugin.
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
327
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
328 * 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
329 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
330 a :ref:`revision mechanism <revisions>` to prevent concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
331 updates.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
332
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
333 * 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
334 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
335 DICOM resources (patients, studies, series and instances) are indeed
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
336 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
337 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
338 if multiple viewers must connect to Orthanc. In `Kubernetes
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
339 <https://kubernetes.io/>`__, concurrent accesses also make it
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
340 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
341 <https://kubernetes.io/docs/concepts/workloads/controllers/deployment/>`__).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
342
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
343 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
344 Kubernetes replicas, notably:
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
345
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
346 - 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
347 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
348 Orthanc.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
349
1002
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
350 - Similarly, each Orthanc instance maintains its own :ref:`status
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
351 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
352 ``IsStable`` information is local to each Orthanc instance.
6b959b4823aa note about stable resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1001
diff changeset
353
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
354 - 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
355 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
356 options ``DicomModalitiesInDatabase`` and
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
357 ``OrthancPeersInDatabase`` are set to ``true``.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
358
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
359 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
360 three possibilities: (1) Introduce a distinguished Orthanc server
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
361 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
362 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
363 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
364 <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
365 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
366 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
367
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
368
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
369 Latency
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
370 ^^^^^^^
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 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
373 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
374 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
375 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
376 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
377 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
378 is expected to have correct performances.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
379
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
380 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
381 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
382 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
383 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
384 aggregate even more SQL requests.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
385
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
386 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
387 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
388 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
389 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
390 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
391 concluded before starting another one. Having multiple connections
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
392 makes the latency problem much less important.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
393
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
394
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
395 Slow deletions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
396 ^^^^^^^^^^^^^^
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
397
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
398 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
399 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
400 might sound counter-intuitive). This is especially true with HDD
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
401 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
402 <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
403 a 20 times speedup by switching from HDD to SSD).
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
404
861
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
405 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
406 the :ref:`Delayed Deletion plugin <delayed-deletion-plugin>` .
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
407 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
408 deletion from the filesystem is done asynchronously in a
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
409 separate thread.