-
Notifications
You must be signed in to change notification settings - Fork 170
Suro Client
There are two types of Suro clients, synchronous and asynchronous. Synchronous client sends messages or message set one at a time synchronously to ensure each message is delivered to Suro server. A synchronous client is blocked after sending a message before receiving ACK from Suro server. An asynchronous Suro client adds messages it needs to send to a queue first, and then asynchronous consumes the messages on the queue, and then sends them out. Messages are batched, and the batch size is configurable. In case some messages are of low volume, users can specify maximum wait time for messages too. An asynchronous client will send out its message set regardless the batch size if the maximum wait time has passed.
Suro client employs connection pooling. It tries to keep at most one connection to a Suro server whenever possible. Connection pool is the singleton object. If the number of senders is greater than that of Suro servers, extra connections will be created and managed out side of connection pool because Thrift client is not thread-safe. The retention period of a connection can be tuned to minimize synchronization overhead.
User can choose an in-memory queue or file-backed queue. Using in-memory queue results in 25% higher throughput than file-backed queue. However, when Suro client cannot keep up with the incoming messages, the bounded in-memory queue will drop messages. In contrast, a file-backed queue has much larger bounds because disk is usually much larger than memory, which means much lower chance of potential message loss. The file-backed queue is bigqueue.