annotate Sphinx/source/faq/scalability.rst @ 946:d7f03f325544

LastUpdate for delete
author Alain Mazy <am@osimis.io>
date Mon, 22 May 2023 18:01:31 +0200
parents 49b863e47c39
children 0b89127439b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _scalability:
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 Scalability of Orthanc
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 ======================
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
6 .. contents::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
7
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
8 Overview
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
9 --------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
10
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 One of the most common question about Orthanc is: *"How many DICOM
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 instances can be stored by Orthanc?"*
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
14 The source code of Orthanc imposes no such hard limit by itself.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
15
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
16 At the time of writing, we know that Orthanc is being used in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
17 production in hospitals with more than 15TB of data, 125,000 studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
18 and around 50 millions of instances (please `get in touch with us
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
19 <https://www.orthanc-server.com/static.php?page=contact>`__ if you can
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
20 share other testimonials). Other users have even reported more than
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
21 28TB of data. Here are links to some testimonials that were published
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
22 on the `Orthanc Users
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
23 <https://groups.google.com/forum/#!forum/orthanc-users>`__ discussion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
24 group: `1
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
25 <https://groups.google.com/d/msg/orthanc-users/-L0D1c2y6rw/KmWnwEijAgAJ>`__,
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
26 `2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
27 <https://groups.google.com/d/msg/orthanc-users/-L0D1c2y6rw/nLXxtYzuCQAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
28 `3
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
29 <https://groups.google.com/d/msg/orthanc-users/s5-XlgA2BEY/ZpYagqBwAAAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
30 `4
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
31 <https://groups.google.com/d/msg/orthanc-users/A4hPaJo439s/NwR6zk9FCgAJ>`__,
317
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
32 `5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 316
diff changeset
33 <https://groups.google.com/d/msg/orthanc-users/Z5cLwbVgJc0/SxVzxF7ABgAJ>`__,
316
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
34 `6
6cd4a86e1e4a size testimonials
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
35 <https://groups.google.com/d/msg/orthanc-users/6tGNOqlUk-Q/vppkAYnFAQAJ>`__...
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
36
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
37 The stress is actually put on the underlying database engine, and on
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
38 the storage area (check out :ref:`orthanc-storage`). As explained in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
39 the :ref:`troubleshooting section <troubleshooting>`, the built-in
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
40 SQLite database engine should be replaced by an enterprise-ready
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
41 database engine once Orthanc must store several hundreds of thousands
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
42 of DICOM instances (check out the :ref:`postgresql` and
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
43 :ref:`mysql`). It is also true that the performance of Orthanc in the
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
44 presence of large databases has continuously improved over time,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
45 especially when it comes to the speed of :ref:`DICOM C-FIND
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
46 <dicom-find>`.
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
48
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
49 .. _scalability-setup:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
50
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
51 Recommended setup for best performance
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
52 --------------------------------------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
53
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Here is a generic setup that should provide best performance in the
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 presence of large databases:
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
933
a5e7e7001316 Orthanc 1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 914
diff changeset
57 * Make sure to use the latest release of Orthanc (1.12.0 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
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
66 case. Note that all pre-built binaries provided by Osimis are
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
67 correctly configured in that respect.
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
68
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 * We suggest to use the default filesystem storage area. Of course,
190
5444374c4202 faq: Fix typo: "backup" -> "backed up"
Thibault Nélis <tn@osimis.io>
parents: 189
diff changeset
70 make sure that the filesystem is properly backed up, and that
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 technologies such as RAID are enabled. Make sure that the option
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ``EnableStorage`` of the PostgreSQL plugins is set to ``false``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 * Obviously, the PostgreSQL database should be stored on a high-speed
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 drive (SSD). This is less important for the storage area.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
315
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
77 * It may be useful to store the PostgreSQL database on another drive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
78 than the storage area. This should improve the use of the available
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
79 bandwidth to the disks.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
80
831
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
81 * If your Orthanc instance is performing a lot of IO requests in parallel
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
82 e.g because many clients are reading/writing DICOM files at the same
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
83 time, you should consider using an :ref:`object storage <object-storage>`
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
84 plugin to store your files.
2feb91573a2b scalability
Alain Mazy <am@osimis.io>
parents: 825
diff changeset
85
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 * The :ref:`Orthanc configuration file <configuration>` should have
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 the following values for performance-related options (but make sure
189
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
88 to understand their implications):
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 * ``StorageCompression = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 * ``LimitFindResults = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 * ``LimitFindInstances = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 * ``KeepAlive = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 * ``TcpNoDelay = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 * ``StorageAccessOnFind = Never``
663
fcb215df05cb savejobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 646
diff changeset
96 * Consider adding ``SaveJobs = false``
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
98 * 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
99 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
100 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
101 ``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
102 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
103 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
104
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
105 * 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
106 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
107 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
108 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
109 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
110 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
111
839
c29ac12e3160 Orthanc-1.11.0
Alain Mazy <am@osimis.io>
parents: 837
diff changeset
112 * 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
113 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
114 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
115 especially WADO-RS Retrieve Metadata.
66ff2f30afcc added new features from next upcoming Orthanc release
Alain Mazy <am@osimis.io>
parents: 831
diff changeset
116
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 * Make sure to carefully :ref:`read the logs <log>` in ``--verbose``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 mode, especially at the startup of Orthanc. The logs may contain
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 very important information regarding performance.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
121 * Make sure to read guides about the `tuning of PostgreSQL
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 <https://wiki.postgresql.org/wiki/Performance_Optimization>`__.
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
123
620
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
124 * Make sure to enable the `Autovacuum Daemon
0b93fcc8162f note about autovacuum in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
125 <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
126 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
127 the PostgreSQL database in order to `reclaim the storage space
532
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
128 <https://www.postgresql.org/docs/current/sql-vacuum.html>`__ that is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
129 occupied by rows that have been deleted from the database (e.g. in a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
130 cron job).
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 528
diff changeset
131
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
132 * You might also be interested in checking the options related to
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
133 :ref:`security <security>`.
309
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
134
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
135 * Consider using filesystems that are known to achieve high
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
136 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
137 `Btrfs <https://en.wikipedia.org/wiki/Btrfs>`__ on GNU/Linux
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
138 distributions.
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
139
746
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
140 * 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
141 you can consider the following solutions:
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
142
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
143 - 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
144 ``StorageDirectory`` :ref:`configuration option <configuration>`
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
145 accordingly.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
146 - :ref:`Replicate <replication>` your current instance of Orthanc
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
147 onto another instance of Orthanc with a larger storage area.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
148 - On GNU/Linux distributions, check out `LVM (Logical Volume Manager)
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
149 <https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)>`__.
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
150 - On Microsoft Windows, check out the so-called "`Storage Spaces
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
151 <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
152 - 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
153 distributed mode in conjunction with the :ref:`AWS S3 plugin
b2b1ba11faaa grow storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 745
diff changeset
154 <minio>` for Orthanc.
318
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
155
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
156 * 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
157 consider setting configuration option ``StudiesMetadata`` to
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
158 ``MainDicomTags``.
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
159
631
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
160 * 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
161 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
162 minimal, Osimis has observed an impact on performance.
9fa56c042d92 postgresql performance on azure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 623
diff changeset
163
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
164
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
165 .. _scalability-memory:
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 Controlling memory usage
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
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
170 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
171 <https://valgrind.org/>`__.
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 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
174 consumption
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
175 <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
176 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
177 upload multiple large DICOM files using the REST API.
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 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
180 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
181 arenas <https://sourceware.org/glibc/wiki/MallocInternals>`__ are
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
182 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
183 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
184 Orthanc (default value of the ``HttpThreadsCount`` option) allocates
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
185 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
186 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
187 properly free all the buffers.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
188
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
189 .. highlight:: bash
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 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
192 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
193 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
194 environment variable ``MALLOC_ARENA_MAX``. For instance, the following
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
195 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
196 threads in Orthanc::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
197
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
198 $ MALLOC_ARENA_MAX=1 ./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 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
201 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
202 use 5 arenas::
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=5 ./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 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
207 options available as environment variables that could also reduce
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
208 memory consumption (for instance, ``MALLOC_MMAP_THRESHOLD_`` would
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
209 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
210 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
211 of ``mallopt()`` for more information.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
212
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
213 **Status:**
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
214
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
215 * 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
216 automatically sets ``MALLOC_MMAP_THRESHOLD_`` (defaults to ``5``)
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
217 during the startup of Orthanc.
623
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
218
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
219 * 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
220 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
221 release 1.6.1** (cf. `changeset
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
222 <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
223
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
224 * The ``osimis/orthanc`` images automatically set
b6ac092360ab note about MALLOC_ARENA_MAX and Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 620
diff changeset
225 ``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
226
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
227
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
228 .. _scalability-limitations:
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 Known 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
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
233 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
234 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
235
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
236 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
237 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
238 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
239 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
240 concurrent access to the DB.
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 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
243 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
244 presented in this `sample
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
245 <https://bitbucket.org/osimis/orthanc-setup-samples/src/master/docker/multiple-orthancs-on-same-db/>`__.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
246 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
247 "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
248 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
249 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
250 conflicts between several instances of Orthanc that would
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
251 simultaneously write to the database.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
252
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
253 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
254 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
255 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
256 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
257 ``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
258 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
259 also modify the database).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
260
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
261 Some issues reported in our bug tracker are related this limitation:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
262 `issue 83 <https://bugs.orthanc-server.com/show_bug.cgi?id=83>`__,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
263 `issue 121 <https://bugs.orthanc-server.com/show_bug.cgi?id=121>`__,
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
264 `issue 151 <https://bugs.orthanc-server.com/show_bug.cgi?id=151>`__.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
265
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
266 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
267 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
268 rewritten.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
269
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
270
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
271 .. _multiple-writers:
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 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
274 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
275
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
276 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
277 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
278 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
279 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
280 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
281 transactions to the database.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
282
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
283 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
284 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
285 concurrency. Read-only database transactions are also distinguished
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
286 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
287 further optimize the patterns of access.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
288
646
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
289 Summarizing, the **multiple readers/writers** is now possible. Here is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
290 a drawing representing a possible deployment with 4 Orthanc servers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
291 all sharing the same DICOM images, with some servers handling multiple
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
292 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
293
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
294 .. image:: ../images/2021-04-22-MultipleWriters.png
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
295 :align: center
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
296 :width: 500px
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
297
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
298 Care must be taken to the following aspects:
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
299
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
300 * 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
301 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
302 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
303 not** support multiple writers.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
304
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
305 * 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
306 transactions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
307 <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
308 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
309 same time (cf. ``ErrorCode_DatabaseCannotSerialize`` in the source
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
310 code of Orthanc). Orthanc will **automatically replay such
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
311 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
312 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
313 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
314 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
315 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
316 of concurrent transactions).
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
317
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
318 * 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
319 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
320 a :ref:`revision mechanism <revisions>` to prevent concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
321 updates.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
322
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
323 * 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
324 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
325 DICOM resources (patients, studies, series and instances) are indeed
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
326 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
327 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
328 if multiple viewers must connect to Orthanc. In `Kubernetes
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
329 <https://kubernetes.io/>`__, concurrent accesses also make it
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
330 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
331 <https://kubernetes.io/docs/concepts/workloads/controllers/deployment/>`__).
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
332
752
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
333 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
334 Kubernetes replicas, notably:
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
335
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
336 - 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
337 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
338 Orthanc.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
339
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
340 - 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
341 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
342 options ``DicomModalitiesInDatabase`` and
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
343 ``OrthancPeersInDatabase`` are set to ``true``.
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
344
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
345 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
346 three possibilities: (1) Introduce a distinguished Orthanc server
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
347 that is responsible to take care of all the jobs (including
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
348 modalities and peers), (2) create an :ref:`Orthanc plugin <plugins>`
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
349 (e.g. using :ref:`Python <python-plugin>`) that queries all the
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
350 Orthanc in the cluster and that aggregates all of their answers,
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
351 or (3) do the same using a higher-level framework (such as Node.js).
9b8fb1b37638 added notes about concurrency
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 746
diff changeset
352
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
353
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
354 Latency
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
355 ^^^^^^^
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
356
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
357 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
358 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
359 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
360 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
361 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
362 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
363 is expected to have correct performances.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
364
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
365 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
366 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
367 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
368 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
369 aggregate even more SQL requests.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
370
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
371 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
372 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
373 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
374 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
375 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
376 concluded before starting another one. Having multiple connections
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
377 makes the latency problem much less important.
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
378
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 Slow deletions
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 640
diff changeset
381 ^^^^^^^^^^^^^^
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
382
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
383 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
384 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
385 might sound counter-intuitive). This is especially true with HDD
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
386 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
387 <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
388 a 20 times speedup by switching from HDD to SSD).
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
389
861
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
390 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
391 the :ref:`Delayed Deletion plugin <delayed-deletion-plugin>` .
c3e169fe22da delayed deletion
Alain Mazy <am@osimis.io>
parents: 860
diff changeset
392 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
393 deletion from the filesystem is done asynchronously in a
777
5caf286f8a0a note about ssd
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 763
diff changeset
394 separate thread.