@@ -19,12 +19,82 @@ Usage
19
19
20
20
You'll need to instantiate the channel layer with a path prefix to create
21
21
IPC objects underneath; any channel layers with the same prefix will talk to
22
- each other.
23
-
24
- * ``prefix ``: Prefix to use for IPC objects in the root namespace. Defaults to ``asgi ``.
22
+ each other as long as they're on the same machine.
25
23
26
24
Example::
27
25
28
26
channel_layer = IPCChannelLayer(
29
27
prefix="aeracode",
28
+ channel_memory=200 * 1024 * 1024,
30
29
)
30
+
31
+ prefix
32
+ ~~~~~~
33
+
34
+ Prefix to use for IPC objects under the root namespace. Defaults to ``asgi ``.
35
+ IPC layers on the same machine with the same prefix will talk to each other.
36
+
37
+ channel_memory
38
+ ~~~~~~~~~~~~~~
39
+
40
+ The amount of shared memory to allocate to the channel storage, in bytes.
41
+ Defaults to 100MB. All of your in-flight messages must fit into this,
42
+ otherwise you'll get ``ChannelFull `` errors if the memory space is full up.
43
+
44
+ ASGI messages can be a maximum of one megabyte, and are usually much smaller.
45
+ The IPC routing metadata on top of each message is approximately 50 bytes.
46
+
47
+ group_memory
48
+ ~~~~~~~~~~~~
49
+
50
+ The amount of shared memory to allocate to the group storage, in bytes.
51
+ Defaults to 20MB. All of your group membership data must fit into this space,
52
+ otherwise your group memberships may fail to persist.
53
+
54
+ You can fit approximately 4000 group-channel membership associations into one
55
+ megabyte of memory.
56
+
57
+ expiry
58
+ ~~~~~~
59
+
60
+ Message expiry in seconds. Defaults to ``60 ``. You generally shouldn't need
61
+ to change this, but you may want to turn it down if you have peaky traffic you
62
+ wish to drop, or up if you have peaky traffic you want to backlog until you
63
+ get to it.
64
+
65
+ group_expiry
66
+ ~~~~~~~~~~~~
67
+
68
+ Group expiry in seconds. Defaults to ``86400 ``. Interface servers will drop
69
+ connections after this amount of time; it's recommended you reduce it for a
70
+ healthier system that encourages disconnections.
71
+
72
+ capacity
73
+ ~~~~~~~~
74
+
75
+ Default channel capacity. Defaults to ``100 ``. Once a channel is at capacity,
76
+ it will refuse more messages. How this affects different parts of the system
77
+ varies; a HTTP server will refuse connections, for example, while Django
78
+ sending a response will just wait until there's space.
79
+
80
+ channel_capacity
81
+ ~~~~~~~~~~~~~~~~
82
+
83
+ Per-channel capacity configuration. This lets you tweak the channel capacity
84
+ based on the channel name, and supports both globbing and regular expressions.
85
+
86
+ It should be a dict mapping channel name pattern to desired capacity; if the
87
+ dict key is a string, it's intepreted as a glob, while if it's a compiled
88
+ ``re `` object, it's treated as a regular expression.
89
+
90
+ This example sets ``http.request `` to 200, all ``http.response! `` channels
91
+ to 10, and all ``websocket.send! `` channels to 20::
92
+
93
+ channel_capacity={
94
+ "http.request": 200,
95
+ "http.response!*": 10,
96
+ re.compile(r"^websocket.send\!.+"): 20,
97
+ }
98
+
99
+ If you want to enforce a matching order, use an ``OrderedDict `` as the
100
+ argument; channels will then be matched in the order the dict provides them.
0 commit comments