Skip to content
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

Persistence: Slow reading of big snapshots #3422

Closed
TietoOliverKurowski opened this issue Apr 26, 2018 · 5 comments
Closed

Persistence: Slow reading of big snapshots #3422

TietoOliverKurowski opened this issue Apr 26, 2018 · 5 comments

Comments

@TietoOliverKurowski
Copy link
Contributor

We are seeing very slow performance when reading big snapshots on SQL Server.

Snapshots of some of your actors are in the range of over 100MB. Reading that snapshot takes around 15 minutes and causes 30% CPU usage.
I traced the issue down to the way the data reader is created:

using (var reader = await command.ExecuteReaderAsync(cancellationToken))

when I use the option CommandBehavior.SequentialAccess reading only takes around 2 seconds and no CPU usage.

Would it be possible to add that parameter?

  • Which Akka.Net version you are using: 1.3.6
  • Akka.Persistence.SqlServer: 1.3.2
  • On which platform you are using Akka.Net: .Net 4.7.1, targeting 4.5.2

In parallel I'm working in getting the snapshot smaller.

@Aaronontheweb
Copy link
Member

Thanks for reporting this! And yep, we can send in a PR to https://github.com/akkadotnet/Akka.Persistence.SqlServer to get that fixed.

@Aaronontheweb
Copy link
Member

Although actually, that might be an issue with the Persistence.Sql.Common middleware in this project

@Horusiath
Copy link
Contributor

Horusiath commented Apr 27, 2018

I can do it, but it may take me some time (I'm still working on other stuff). I think, it's something that could be even picked up as first contribution. Essentially most of the changes could be closed inside Akka.Persistence.Sql.Common project.

IMO sequential access should be a configurable setting (example path: akka.persistence.snapshot-store.<sql-plugin>.use-sequential-access = true|false). If not provided, it should default to false to keep existing behavior intact.

AbstractQueryExecutor.SelectSnapshotAsync is the place for applying command behavior. Probably an additional parameter will be necessary.

Also this change most probably will hit all existing Sql providers in terms of backward compatibility.

@Aaronontheweb
Copy link
Member

@TietoOliverKurowski, would you be interested in contributing this change? Otherwise one of us on the @akkadotnet/core team can pick it up.

@TietoOliverKurowski
Copy link
Contributor Author

Yes, I want to give it a try. By end of next Friday I should have something working.

@Aaronontheweb Aaronontheweb added this to the 1.3.7 milestone May 3, 2018
Aaronontheweb pushed a commit that referenced this issue May 10, 2018
…s can use Sequential access, which improves reading speed for large payloads. (#3429)

- Added for Snapshot query
- Added for journal queries
This change is not backwards compatible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants