You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Kitex supports short connections, long connection pool, connection multiplexing and connection pool status monitoring."
7
7
---
8
8
9
9
Kitex provides **Short Connection**, **Long Connection Pool** and **Connection Multiplexing** for different business scenarios.
10
-
Kitex uses Long Connection Pool by default after v0.0.2, but adjusting the Pool Config according to your need is suggested.
10
+
Kitex uses **Long Connection Pool by default** after v0.0.2, but adjusting the Pool Config according to your need is suggested.
11
11
12
12
## Short Connection
13
13
14
-
Every request needs to create a connection, the performance is bad, so it is not suggested normally.
15
-
16
-
Enable Short Connection:
14
+
Every request needs to create a connection. The performance is bad, so it is not suggested in most cases. However, short connections should be used in some scenarios. For example, if there are too many instances on the caller side, it will increase the burden on callee services. Please choose according to the situation.
Kitex enable Long Connection Pool after >= v0.0.2, default config params are as below:
25
24
@@ -51,14 +50,14 @@ Parameter description:
51
50
Each downstream address corresponds to a connection pool, the connection pool is a ring composed of connections, and the size of the ring is `MaxIdlePerAddress`.
52
51
53
52
When getting a connection of downstream address, proceed as follows:
54
-
1. Try to fetch a connection from the ring, if fetching failed (no idle connections remained), then try to establish a new connection. In other words, the number of connections may exceed `MaxIdlePerAddress`
53
+
1. Try to fetch a connection from the pool, if fetching failed (no idle connections remained), then try to establish a new connection. In other words, the number of connections may exceed `MaxIdlePerAddress`
55
54
2. If fetching succeed, then check whether the idle time of the connection (since the last time it was placed in the connection pool) has exceeded MaxIdleTimeout. If yes, this connection will be closed and a new connection will be created.
56
55
57
56
When the connection is ready to be returned after used, proceed as follows:
58
57
59
58
1. Check whether the connection is normal, if not, close it directly
60
59
2. Check whether the idle connection number exceeds `MaxIdleGlobal`, and if yes, close it directly
61
-
3. Check whether free space remained in the ring of the target connection pool, if yes, put it into the pool, otherwise close it directly
60
+
3. Check whether free space remained in the pool of the target connection pool. If yes, put it into the pool, otherwise close it directly
62
61
63
62
### Parameter Setting Suggestion
64
63
@@ -68,12 +67,13 @@ The setting of parameters is suggested as follows:
68
67
- For example, the cost of each request is 100ms, and the request spread to each downstream address is 100QPS, the value is suggested to set to 10, because each connection handles 10 requests per second, 100QPS requires 10 connections to handle
69
68
- In the actual scenario, the fluctuation of traffic is also necessary to be considered. Pay attention, the connection within MaxIdleTimeout will be recycled if it is not used
70
69
- Summary: this value be set too large or too small would lead to degenerating to the short connection
71
-
-`MinIdlePerAddress`: Assuming that there are periodic requests and the period is greater than `MaxIdleTimeout`, setting this parameter can avoid creating a new connection every time.
72
-
- The parameter consideration is similar to `MaxIdlePerAddress` and can be set according to the average latency of requests and the throughput.
73
-
- For example, if `MinIdlePerAddress` is set to 5 and the response time of each request is 100ms. 50 requests can be processed per second (50QPS) without creating a new connection.
74
70
-`MaxIdleGlobal`: should be larger than the total number of `downstream targets number * MaxIdlePerAddress`
75
71
- Notice: this value is not very valuable, it is suggested to set it to a super large value. In subsequent versions, considers discarding this parameter and providing a new interface
72
+
- Since v0.7.2, no limit for `MaxIdleGlobal` if not set.
76
73
-`MaxIdleTimeout`: since the server will clean up inactive connections within 10min, the client also needs to clean up long-idle connections in time to avoid using invalid connections. This value cannot exceed 10min when the downstream is also a Kitex service
74
+
-`MinIdlePerAddress` (Kitex >= v0.4.3): Assuming that there are periodic requests and the period is greater than `MaxIdleTimeout`, setting this parameter can avoid creating a new connection every time.
75
+
- The parameter consideration is similar to `MaxIdlePerAddress` and can be set according to the average latency of requests and the throughput.
76
+
- For example, if `MinIdlePerAddress` is set to 5 and the response time of each request is 100ms. 50 requests can be processed per second (50QPS) without creating a new connection.
description: Kitex supports transport protocols of TTHeader、HTTP2.
@@ -29,46 +29,52 @@ Here are the available combination options of transport protocols and message pr
29
29
If you want to use custom implementations for the message or transport protocol, you can find help here [Extension of Codec](/docs/kitex/tutorials/framework-exten/codec/).
30
30
31
31
## Configuration
32
-
33
-
You can configure the transport protocol when initializing the client:
34
-
32
+
### Client
33
+
#### Thrift
34
+
1. Buffered: PurePayload (by default)
35
+
2. configure Framed: prepend a 4-byte (int32) length before the Thrift pure payload
NOTE: if there's no streaming API in the IDL, this option is needed for enabling gRPC protocol, otherwise kitex will only send protobuf binary (not gRPC).
67
64
65
+
### Server
66
+
Multi-protocol is supported by default. Metahandlers should be configured to enable transparent information transmission.
68
67
69
-
// server side no need to config transport protocol
Kitex 目前支持两种传输协议:[TTHeader](../../../reference/transport_protocol_ttheader/)、HTTP2,但实际提供配置的 Transport Protocol 是:TTHeader、GRPC、Framed、TTHeaderFramed、PurePayload。
0 commit comments