I am working on an microservice that is developed using Vertx framework. One of service receives 100s(400 average) of events per second from event bus and it is written to MSSQL DB. Queries are executed using JDBCPool and currently configured with 40 as max number of connection. C3P0 is used for connection pooling.
My problem is, sometime the pool got exhausted and there are lot of statements waiting to be executed and this make whole application un-responsive. If I increase the pool size the DB exhibit slowness which affects other services also. So I am planning to write event to a Queue and poll the event from queue and then write to db, by this way I can control number of connections to DB by increasing/decreasing the number poller instance.
Current design
Source system -> Event bus -> Async IO -> DB
Proposed design
Source system -> Event bus -> Queue -> Polling -> DB
To keep it simple, I am trying to replace the DB IO async part with kind of sync. Code
poll(){
// poll queue with 100ms timeout
//after getting event from queue call dao
dao.insert(event)
.onSuccess(statValObj -> {
poll();
})
}
The above looks like a recursion, so would it impact vertx eventloop?
Can connection pool size limit the number of queries/operation without freezing the entire call stack?
Vertx version - 4.2.0