annotate Sphinx/source/faq/scalability.rst @ 490:933e28b6a64d

Orthanc 1.7.3
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 24 Aug 2020 08:05:10 +0200
parents a10f0e5be459
children f22b3743fd3f
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
490
933e28b6a64d Orthanc 1.7.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 461
diff changeset
57 * Make sure to use the latest release of Orthanc (1.7.3 at the time of
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 writing).
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 * We suggest to use the latest release of the :ref:`PostgreSQL plugin
219
3518e3f56738 PostgreSQL 3.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 215
diff changeset
61 <postgresql>` to store the database index (3.2 at the time of
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 writing). Make sure that ``EnableIndex`` is set to ``true``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
64 * Make sure that :ref:`run-time debug assertions <troubleshooting>`
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
65 are turned off. A warning will show in the logs if this is not the
188
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
66 case. Note that all pre-built binaries provided by Osimis are
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 187
diff changeset
67 correctly configured in that respect.
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
68
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 * We suggest to use the default filesystem storage area. Of course,
190
5444374c4202 faq: Fix typo: "backup" -> "backed up"
Thibault Nélis <tn@osimis.io>
parents: 189
diff changeset
70 make sure that the filesystem is properly backed up, and that
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 technologies such as RAID are enabled. Make sure that the option
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ``EnableStorage`` of the PostgreSQL plugins is set to ``false``.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 * Obviously, the PostgreSQL database should be stored on a high-speed
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 drive (SSD). This is less important for the storage area.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
315
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
77 * It may be useful to store the PostgreSQL database on another drive
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
78 than the storage area. This should improve the use of the available
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
79 bandwidth to the disks.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 309
diff changeset
80
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 * The :ref:`Orthanc configuration file <configuration>` should have
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 the following values for performance-related options (but make sure
189
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 188
diff changeset
83 to understand their implications):
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 * ``StorageCompression = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 * ``LimitFindResults = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 * ``LimitFindInstances = 100``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 * ``KeepAlive = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 * ``TcpNoDelay = true``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 * ``SaveJobs = false``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 * ``StorageAccessOnFind = Never``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 * Make sure to carefully :ref:`read the logs <log>` in ``--verbose``
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 mode, especially at the startup of Orthanc. The logs may contain
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 very important information regarding performance.
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
187
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 186
diff changeset
97 * Make sure to read guides about the `tuning of PostgreSQL
186
a846a8f6d9a6 scalability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 <https://wiki.postgresql.org/wiki/Performance_Optimization>`__.
238
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
99
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
100 * You might also be interested in checking the options related to
a363714813b2 securing orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 220
diff changeset
101 :ref:`security <security>`.
309
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
102
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
103 * Consider using filesystems that are known to achieve high
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
104 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
105 `Btrfs <https://en.wikipedia.org/wiki/Btrfs>`__ on GNU/Linux
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
106 distributions.
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
107
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
108 * On GNU/Linux distributions, `LVM (Logical Volume Manager)
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
109 <https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)>`__
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
110 can be used to dynamically and easily grow the storage area as more
f18fdcbeba26 xfs, btrfs, lvm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 290
diff changeset
111 space becomes needed.
318
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
112
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
113 * 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
114 consider setting configuration option ``StudiesMetadata`` to
83d822f11e78 SeriesMetadata and StudiesMetadata in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 317
diff changeset
115 ``MainDicomTags``.
384
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
116
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
117
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
118 .. _scalability-memory:
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
119
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
120 Controlling memory usage
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
121 ------------------------
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
122
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
123 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
124 <https://valgrind.org/>`__.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
125
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
126 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
127 consumption
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
128 <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
129 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
130 upload multiple large DICOM files using the REST API.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
131
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
132 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
133 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
134 arenas <https://sourceware.org/glibc/wiki/MallocInternals>`__ are
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
135 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
136 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
137 Orthanc (default value of the ``HttpThreadsCount`` option) allocates
0fb9369e893e Orthanc 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
138 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
139 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
140 properly free all the buffers.
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
141
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
142 .. highlight:: bash
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
143
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
144 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
145 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
146 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
147 environment variable ``MALLOC_ARENA_MAX``. For instance, the following
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
148 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
149 threads in Orthanc::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
150
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
151 $ MALLOC_ARENA_MAX=1 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
152
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
153 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
154 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
155 use 5 arenas::
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
156
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
157 $ MALLOC_ARENA_MAX=5 ./Orthanc
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
158
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
159 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
160 options available as environment variables that could also reduce
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
161 memory consumption (for instance, ``MALLOC_MMAP_THRESHOLD_`` would
e4b0a4d69f42 note about memory usage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
162 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
163 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
164 of ``mallopt()`` for more information.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
165
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
166
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
167 .. _scalability-limitations:
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
168
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
169 Known limitations
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
170 -----------------
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
171
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
172 Exclusive access to the DB
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
173 ^^^^^^^^^^^^^^^^^^^^^^^^^^
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
174
490
933e28b6a64d Orthanc 1.7.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 461
diff changeset
175 As of Orthanc 1.7.3, the internal code accessing the DB is still affected
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
176 by limitations induced by the SQLite engine that was the only one originally
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
177 available at the beginning of the project: inside a single Orthanc process,
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
178 there is no concurrent access to the DB.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
179
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
180 One solution to avoid this limitation is to have multiple Orthanc accessing
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
181 the same DB (works only for MySQL and PostgreSQL) as presented in this `sample
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
182 <https://bitbucket.org/osimis/orthanc-setup-samples/src/master/docker/multiple-orthancs-on-same-db/>`__.
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
183
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
184 Also note that the core of Orthanc does not currently support the replay
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
185 of database transactions, which is necessary to deal with conflicts
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
186 between several instances of Orthanc that would simultaneously write
490
933e28b6a64d Orthanc 1.7.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 461
diff changeset
187 to the database. As a consequence, as of Orthanc 1.7.3, when connecting multiple
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
188 Orthanc to a single database by setting ``Lock`` to ``false``, there
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
189 should only be one instance of Orthanc acting as a writer and all the
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
190 other instances of Orthanc acting as readers only. Be careful to set
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
191 the option ``SaveJobs`` to ``false`` in the configuration file of all
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
192 the instances of Orthanc acting as readers.
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
193
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
194 A refactoring is needed to improve the core of Orthanc in that
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
195 respect, for which we are looking for funding from the
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
196 industry. Some issues reported in our bug tracker call for this
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
197 refactoring: `issue 83
445
987fbbc2b59e leaving bitbucket wrt. bug tracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 441
diff changeset
198 <https://bugs.orthanc-server.com/show_bug.cgi?id=83>`__, `issue 121
987fbbc2b59e leaving bitbucket wrt. bug tracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 441
diff changeset
199 <https://bugs.orthanc-server.com/show_bug.cgi?id=121>`__, `issue 151
987fbbc2b59e leaving bitbucket wrt. bug tracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 441
diff changeset
200 <https://bugs.orthanc-server.com/show_bug.cgi?id=151>`__.
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
201
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
202
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
203 Latency
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
204 ^^^^^^^
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
205
490
933e28b6a64d Orthanc 1.7.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 461
diff changeset
206 As of Orthanc 1.7.3, Orthanc still performs quite a large number of small
440
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
207 SQL requests. A simple request to a route like ``/studies/{id}`` can trigger
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
208 6 SQL queries.
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
209
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
210 This is not an ideal situation and this might be addressed
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
211 in a future larger DB refactoring (the most time-consuming queries have already
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
212 been optimized). Given the large number of round-trips
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
213 between Orthanc and the DB server, it's important that the latency is reduced
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
214 as much as possible. I.e, if deploying Orthanc in a cloud infrastructure,
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
215 make sure that the DB server and Orthanc VMs are located in the same datacenter.
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
216
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
217 Typically, a latency of 1-4 ms is expected to have correct performances. If your
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
218 latency is 20ms, a simple request to ``/studies/{id}`` might spend 120ms in
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
219 round-trip alone.
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
220
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
221
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
222
86bf70a1f570 scalability: latency
Alain Mazy <alain@mazy.be>
parents: 438
diff changeset
223