Commit b835d665c3b14a95c66b3fd350a7aea4f3befc6a

Authored by Andrew Shvayka
1 parent 9b1c59a9

Few performance tuning parameters

... ... @@ -87,6 +87,7 @@ mqtt:
87 87 leak_detector_level: "${NETTY_LEASK_DETECTOR_LVL:DISABLED}"
88 88 boss_group_thread_count: "${NETTY_BOSS_GROUP_THREADS:1}"
89 89 worker_group_thread_count: "${NETTY_WORKER_GROUP_THREADS:12}"
  90 + max_payload_size: "${NETTY_MAX_PAYLOAD_SIZE:65536}"
90 91 # MQTT SSL configuration
91 92 ssl:
92 93 # Enable/disable SSL support
... ...
... ... @@ -60,6 +60,10 @@ public abstract class AbstractCassandraCluster {
60 60 private long initTimeout;
61 61 @Value("${cassandra.init_retry_interval_ms}")
62 62 private long initRetryInterval;
  63 + @Value("${cassandra.max_requests_per_connection_local:128}")
  64 + private int max_requests_local;
  65 + @Value("${cassandra.max_requests_per_connection_remote:128}")
  66 + private int max_requests_remote;
63 67
64 68 @Autowired
65 69 private CassandraSocketOptions socketOpts;
... ... @@ -90,8 +94,8 @@ public abstract class AbstractCassandraCluster {
90 94 .withClusterName(clusterName)
91 95 .withSocketOptions(socketOpts.getOpts())
92 96 .withPoolingOptions(new PoolingOptions()
93   - .setMaxRequestsPerConnection(HostDistance.LOCAL, 32768)
94   - .setMaxRequestsPerConnection(HostDistance.REMOTE, 32768));
  97 + .setMaxRequestsPerConnection(HostDistance.LOCAL, max_requests_local)
  98 + .setMaxRequestsPerConnection(HostDistance.REMOTE, max_requests_remote));
95 99 this.clusterBuilder.withQueryOptions(queryOpts.getOpts());
96 100 this.clusterBuilder.withCompression(StringUtils.isEmpty(compression) ? Compression.NONE : Compression.valueOf(compression.toUpperCase()));
97 101 if (ssl) {
... ...
... ... @@ -33,8 +33,6 @@ import org.thingsboard.server.transport.mqtt.adaptors.MqttTransportAdaptor;
33 33 */
34 34 public class MqttTransportServerInitializer extends ChannelInitializer<SocketChannel> {
35 35
36   - private static final int MAX_PAYLOAD_SIZE = 64 * 1024 * 1024;
37   -
38 36 private final SessionMsgProcessor processor;
39 37 private final DeviceService deviceService;
40 38 private final DeviceAuthService authService;
... ... @@ -42,10 +40,11 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha
42 40 private final MqttTransportAdaptor adaptor;
43 41 private final MqttSslHandlerProvider sslHandlerProvider;
44 42 private final QuotaService quotaService;
  43 + private final int maxPayloadSize;
45 44
46 45 public MqttTransportServerInitializer(SessionMsgProcessor processor, DeviceService deviceService, DeviceAuthService authService, RelationService relationService,
47 46 MqttTransportAdaptor adaptor, MqttSslHandlerProvider sslHandlerProvider,
48   - QuotaService quotaService) {
  47 + QuotaService quotaService, int maxPayloadSize) {
49 48 this.processor = processor;
50 49 this.deviceService = deviceService;
51 50 this.authService = authService;
... ... @@ -53,6 +52,7 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha
53 52 this.adaptor = adaptor;
54 53 this.sslHandlerProvider = sslHandlerProvider;
55 54 this.quotaService = quotaService;
  55 + this.maxPayloadSize = maxPayloadSize;
56 56 }
57 57
58 58 @Override
... ... @@ -63,7 +63,7 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha
63 63 sslHandler = sslHandlerProvider.getSslHandler();
64 64 pipeline.addLast(sslHandler);
65 65 }
66   - pipeline.addLast("decoder", new MqttDecoder(MAX_PAYLOAD_SIZE));
  66 + pipeline.addLast("decoder", new MqttDecoder(maxPayloadSize));
67 67 pipeline.addLast("encoder", MqttEncoder.INSTANCE);
68 68
69 69 MqttTransportHandler handler = new MqttTransportHandler(processor, deviceService, authService, relationService,
... ...
... ... @@ -82,7 +82,8 @@ public class MqttTransportService {
82 82 private Integer bossGroupThreadCount;
83 83 @Value("${mqtt.netty.worker_group_thread_count}")
84 84 private Integer workerGroupThreadCount;
85   -
  85 + @Value("${mqtt.netty.max_payload_size}")
  86 + private Integer maxPayloadSize;
86 87
87 88 private MqttTransportAdaptor adaptor;
88 89
... ... @@ -106,7 +107,7 @@ public class MqttTransportService {
106 107 b.group(bossGroup, workerGroup)
107 108 .channel(NioServerSocketChannel.class)
108 109 .childHandler(new MqttTransportServerInitializer(processor, deviceService, authService, relationService,
109   - adaptor, sslHandlerProvider, quotaService));
  110 + adaptor, sslHandlerProvider, quotaService, maxPayloadSize));
110 111
111 112 serverChannel = b.bind(host, port).sync().channel();
112 113 log.info("Mqtt transport started!");
... ...