-
Notifications
You must be signed in to change notification settings - Fork 142
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
batch insert event and event_tag performance. #710
Comments
Skepticism is pointless. After a thorough investigation, it was found that akka-persistence-jdbc/slick does not even use Driver's normal/leaderdegradation/oldestreduce active pods to singleactive podsinactive pods |
ConclusionAfter investigation, I found that once the event of persistence Actor is tagged, the delay of persistence to the database will increase very seriously. For some nodes, it may be 10x time. the reason why DAO degraded because when event has tag, it's will return to foreach insert, not batch insert. Slick not support insertAndReturn using batch.what happen on my caseAccording to the source code, batches insert event with tag will definitely cause performance degradation. In my case, it happened randomly, and I verified this problem under cluster and stand-alone respectively. Generally speaking, if the traffic given to In my application, due to sharding (my guess), some traffic may be delayed to reach other nodes, which causes the node to receive both |
i think this was related on #592 |
yep, i'm working on it. I fork this repository and change the source code base on #592, packaged it and uploaded it to our Maven repository (I am not familiar with scala, sbt publish stuck me most of the time, and finally solved it through maven deploy-file) I am using same load test for this, but has more case:
In case 3, the profiler CPU hotspot report tells us that #592 can solve this problem! And my application monitor prove the same conclusion. "Slice Executor" duration metrics in all tests (no more peaks happen on load): After fixing the batch insertion problem, my application throughput increased from 1000 up to 4000(Kryo serialization is the next bottleneck for now.) finally, this is my change of #592, i am not familiar with scala, so maybe i missing some blind spot, And one more thing, in my tests, i did't using projection. On my opinion, PR show my change: #731 |
* Replace event_tag FK to get rid of insert and return akka#710 * support rolling updates akka#710 * remove CRLF akka#710 * optimized migrator akka#710 * fixes oracle test akka#710 * unitTest,SQL for migration akka#710 * fix MigratorSpec akka#710 * chore: typo fix akka#710 * fix: IntegrationTest and clean code akka#710 * fix: compatible legacy tag read akka#673 * chore: mi-ma filter for PR * fix: optimized migrate step * fix: dialect for column fill * fix: update migration sql * fix: mysql dialect * fix: dialect syntax * fix: dialect syntax * fix: avoid use system table of mysql * fix: batch insert caused flaky test * fix: insert less event of large batch * fix: script fix and strongly express two-step update
Recently I am doing load testing on my application. it does not really have a good performance, and even can not reach the bottleneck of the database.
I have some questions on the insert model:
on
akka.persistence.jdbc.journal.dao.DefaultJournalDao
, it uses multi insert action++=
akka-persistence-jdbc/core/src/main/scala/akka/persistence/jdbc/journal/dao/DefaultJournalDao.scala
Line 45 in bba266c
And then I took some time to find the source that executes SQL. The multi-insert action implement is
MultiInsertAction
onslick.jdbc.JdbcActionComponent
And it basically just uses
java.sql.Statement#executeBatch
. as far as I know it wouldn't optimize too much on the multi-insert on this method. (Most of the JDBC drivers would not).They just for-each loop every param and fill them to statement and then for-each loop executes it, it will take huge network IO (the bottleneck).
MySQL document points out how to optimize this. https://dev.mysql.com/doc/refman/8.0/en/insert-optimization.html
General, most database support insert values list, it is just one network i/o.
I believe it is a performance issue, and break down the server when the network was degraded. (Expressed as a lot of EventSourcedBehavior complain circuit breakers fail fast).
In the end, In the process of writing down this issue (collecting information), I found the same issue already exists, but on scala slick.
slick/slick#2398 and slick/slick#1272
The text was updated successfully, but these errors were encountered: