forked from zhangxinrun/fubar
-
Notifications
You must be signed in to change notification settings - Fork 2
/
fubar.config
201 lines (168 loc) · 6.22 KB
/
fubar.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
[
{lager, %% Log configurations
[
{handlers,
[
{lager_file_backend,
[
{file, "log/console.log"},
{level, notice}, {size, 104857600}, {date, "$D0"}, {count, 100},
{formatter_config, [date," ",time," [",severity,"] ",message," (",pid," ",module,":",line,")\n"]}
]
},
{lager_file_backend,
[
{file, "log/error.log"},
{level, warning}, {size, 10485760}, {date, "$D0"}, {count, 100},
{formatter_config, [date," ",time," [",severity,"] ",message," (",pid," ",module,":",line,")\n"]}
]
},
{lager_file_backend,
[
{file, "log/stat.log"},
{level, '=alert'}, {size, 10485760}, {date, "$D0"}, {count, 100},
{formatter_config, [date," ",time,",",message,"\n"]}
]
}
]
},
{async_threshold, 10000},
{error_logger_hwm, 100},
{colored, true}
]
},
{fubar,
[
%% fubar_app settings control server socket behavior.
%% THE SETTINGS IN THIS SECTION CAN'T BE CHANGED AT RUNTIME
%% WHILE MOST OTHERS CAN BE UNLESS STATED OTHERWISE.
{fubar_app,
[
%% Number of minimum acceptors in acceptor pool.
{acceptors, 1024},
%% Maximum number of connections allowed.
{max_connections, infinity},
%% Default socket options.
%% These are overridden by socket_options in mqtt_protocol settings.
{options,
[
{backlog, 1024}, {reuseaddr, true}, {linger, {false, 0}},
{send_timeout, 10000},
{certfile, "priv/ssl/cert.pem"}, {keyfile, "priv/ssl/key.pem"},
{reuse_sessions, false}, {verify, verify_none}
]
}
]
},
%% fubar_sysmon sets/clears a node's alarm state.
{fubar_sysmon,
[
% 40% of the total physical memory set as a limit
{high_watermark, 0.4},
% System check interval in milliseconds
{interval, 10000},
% Start offloading to a node with 20% lower load
{offloading_threshold, 1.2}
]
},
%% mqtt_protocol settings control mqtt receiver/parser behavior.
{mqtt_protocol,
[
%% Maximum variable header + payload size per mqtt message.
{max_packet_size, 4096}, % 4kB
%% Socket buffers are set small to accept a lot of clients.
{socket_options, [{recbuf, 4096}, {sndbuf, 4096}]}, % 4kB each
%% Socket buffers for clients from preset addresses have more bandwidth.
{acl_socket_options, [{recbuf, 1048576}, {sndbuf, 1048576}]},
%% Dispatch module handles all the mqtt messages after parsing.
{dispatch, mqtt_server}
]
},
%% websocket_protocol settings control websocket receiver/parser behavior.
{websocket_protocol,
[
%% Maximum variable header + payload size per mqtt message.
{max_packet_size, 4096}, % 4kB
%% Socket buffers are set small to accept a lot of clients.
{socket_options, [{recbuf, 4096}, {sndbuf, 4096}]}, % 4kB each
%% Dispatch module handles all the mqtt messages after parsing.
{dispatch, mqtt_server}
]
},
%% mqtt_server settings control mqtt message handler behavior.
{mqtt_server,
[
%% This server's public IP address
{address, "tcp://127.0.0.1:1883"},
%% The broker closes the connection if a client doesn't send an mqtt connect within given time.
{timeout, 10000}, % 3s
%% mqtt spec states that a client should specify keep-alive value in mqtt connect.
%% But this broker suggests different keep-alive value in mqtt connack
%% if the keep-alive value specified by the client is too small or too big.
%% This is not compliant to mqtt spec but a useful extension.
%% Set this range wide enough if you don't want the extension.
{valid_keep_alive, {1800, 3600}}, % 1 min ~ 1h
%% Module:verify/2 function is used to verify credential in mqtt connect.
%% Uncomment the line below to enable authentication.
{auth, mqtt_account},
%% Alt server (custom load balancing extension) offloading parameters.
{when_overloaded, drop}
]
},
%% mqtt_session settings control mqtt session behavior.
{mqtt_session,
[
%% Offline sessions are expired after some time.
{max_age, 172800000}, % 2 days
%% Maximum transactions waiting for execution.
{max_wait, 10},
%% It drops transactions that are not complete within given time.
{transaction_timeout, 60000}, % 1 min
%% It stores mqtt messages for temporarily offline clients.
%% But the number of offline messages are limited.
{buffer_limit, 3},
%% It sends duplicate mqtt messages to a client for higher qos.
%% Retry interval and maximum number of retries are set in prior.
{max_retries, 5},
{retry_after, 10000}
]
},
%% mqtt_topic settings.
{mqtt_topic, []},
%% mqtt_client settings to be applied by default.
{mqtt_client,
[
%% mqtt broker ip address
{host, "127.0.0.1"},
%% mqtt broker port
{port, 1883},
%% mqtt transport protocol
{transport, ranch_tcp},
%% mqtt credential
{username, <<"">>},
{password, <<"">>},
%% Default handler
{handler, mqtt_client_simple}
]
},
%% Real world simulation parameters.
%% Applies to mqtt_client_killer:start/1, mqtt_client_monitor:start/1
{mqtt_client_killer,
[
%% mean reconnection interval
{mri, 1800}
]
},
{mqtt_client_monitor,
[
%% max clients per second
{max_cps, 10},
%% client id range
{range, {1, 100}},
%% client specification
{mfa, {mqtt_client, start, [[]]}}
]
}
]
}
].