-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JdbcChannelMessageStore: poor performance for long queue of messages #2629
Comments
Not sure why you show a Fully not clear how that
I believe you can do that just right now on your DB and come back to us with the feedback after that. Also I would like to say that framework doesn't call Or you have a problem in other place, or you your problem is really about that poll query, but not count... |
Oh! Sorry, I see the So, I think your idea about extra |
Setting the consumer's receive timeout to 0 will avoid that size() call. |
Yeah... Default one is:
Does it help somehow in your test with Oracle, Gary? I can install MySQL though, to be sure that we do as much testing as possible. |
Yes; I am testing with oracle now; improved a little so far, but not a lot. |
Seems to me, we can replace this
To simply poll() and check for non-null. |
Yeah... Looks like our |
I mean this... long nanos = TimeUnit.MILLISECONDS.toNanos(timeout);
long deadline = System.nanoTime() + nanos;
Message<?> message = this.queue.poll();
while (message == null && nanos > 0) {
this.queueSemaphore.tryAcquire(nanos, TimeUnit.NANOSECONDS); // NOSONAR - ok to ignore result
message = this.queue.poll();
if (message == null) {
nanos = deadline - System.nanoTime();
}
}
return message; |
Looks like you talk about the code in the But I agree that that one has to be fixed as we are discussing it here. |
Oh, right; yes, of course. |
See JIRA https://jira.spring.io/browse/INT-4553 where we are going to remove usage of that |
JIRA: https://jira.spring.io/browse/INT-4553 Fixes spring-projects#2628 Fixes spring-projects#2629 - Avoid `size()` calls on the MGS, use `poll()` instead. - Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.
JIRA: https://jira.spring.io/browse/INT-4553 Fixes spring-projects#2628 Fixes spring-projects#2629 - Avoid `size()` calls on the MGS, use `poll()` instead. - Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.
JIRA: https://jira.spring.io/browse/INT-4553 Fixes spring-projects#2628 Fixes spring-projects#2629 - Avoid `size()` calls on the MGS, use `poll()` instead. - Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.
JIRA: https://jira.spring.io/browse/INT-4553 Fixes spring-projects#2628 Fixes spring-projects#2629 - Avoid `size()` calls on the MGS, use `poll()` instead. - Optimize the indexes for the `INT_CHANNEL_MESSAGE` table.
JIRA: https://jira.spring.io/browse/INT-4553 Fixes #2628 Fixes #2629 - Avoid `size()` calls on the MGS, use `poll()` instead. - Optimize the indexes for the `INT_CHANNEL_MESSAGE` table. Avoid size call when no timeout too. Polishing - PR Comments Missed a doc fix Another missed %PREFIX% Fix underscores Polishing; PR comments; make MGQ extendable. Fix version in doc. * Polishing `@since` * Use diamonds whenever it is possible **Cherry-pick to 5.0.x** # Conflicts: # src/reference/asciidoc/jdbc.adoc # src/reference/asciidoc/whats-new.adoc
Hi,
We recently faced serious performance issues with spring-integration-jdbc:5.0.7 and PostgreSQL 9.5.13.
With DB backed queue containing over 1.8 million messages, the average speed of processing stored data was 2messages per second. After a long investigation we found out, that problem was caused by the function polling messages and more precisely part checking the size of the queue.
For millions of records MessageGroupQueue.size method called following SQL from AbstractChannelMessageStoreQueryProvider.getCountAllMessagesInGroupQuery:
which could take even few seconds to complete (see: slow counting).
Quick fix:
Our workaround consisted on extending PostgresChannelMessageStoreQueryProvider.getCountAllMessagesInGroupQuery method to use faster count method using approach similar to presented here: fast count.
Improvement suggestion
I would suggest changing following part of MessageGroupQueue.poll:
to use new method this.isEmpty(), which for PosgresSQL can run following query:
select exists(select 1 from %PREFIX%channel_message where GROUP_KEY=? and REGION=?)
Using our workaround seems to be not the best solution as it returns only estimated value.
Regards, Kamil
PS. It may be connected to #2628 issue
The text was updated successfully, but these errors were encountered: