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

Database backend for jobs #580

Open
lithorus opened this issue May 11, 2023 · 4 comments
Open

Database backend for jobs #580

lithorus opened this issue May 11, 2023 · 4 comments

Comments

@lithorus
Copy link
Member

The current database is only in memory and restarting the afanasy server service can take quite a long time, since it needs to re-add all jobs again from the JSON files.

With a large job queue it can takes up to 30 min.

The other issue with this kind of setup is that what's on disk does not match what's in memory (the recent problem with custom JSON data on blocks).

My suggestions would be :

  1. Support for postgres database but keep the data as it is now, but use a JSON field in postgres. (but still keep the logs on disk)
  2. Re-structure the data from JSON and make it more native to a relational database.

Another solution could also be something like a redis database, which might be easier to mimic the current implementation.

@timurhai
Copy link
Member

timurhai commented May 15, 2023

Hello, Jimmy!
There are some other issues to speed up server start and reduce memory usage to keep larger amount of jobs.

  1. On start let server solve constructed jobs while it still reads other jobs. It can read jobs from disk in store folder modification order.
  2. Deleted jobs should be stored in some archive at first before a real deletion. This way you reduce the amount of jobs that server keeps in memory. But you can't have a bigger running amount of jobs.
    Archive jobs #240

@lithorus
Copy link
Member Author

Even when clearing the job database with jobs, we still have about 10k as a minimum which takes about 10 min to load on cached files.
I've started doing an experiment with replacing the Jsonwrite function to use redis backend and will make some benchmarks to compare the performance. It just uses the filepath as key which makes it a drop in replacement.

@sebastianelsner
Copy link
Contributor

Hej @lithorus did you get anywhere with this? We are hitting the same issue. It would be great to be able and offload the done jobs so:

  1. they are not all loaded at startup -> faster start -> faster solve cycles -> better responsiveness of afserver
  2. they are stored in a database where we can keep them for an extended amount of time, able to restore if needed, able to see all the data it produced.

@lithorus
Copy link
Member Author

I had a look at replacing the file based json files with a NOSQL database. This way it would keep the same structure, but wanted to test if it was actually any faster. The next step would be to create a proper database structure, but it will be hard to keep compatibility with current implementation.

I might have just do a hard fork with the database work to test it out. Also, I'm looking into why it's so slow at loading at times. Startup of one of our afanasy servers with 17k jobs took about atleast 1 hour to start.

Also it's worth noting that if you change too many jobs at a time, it will crash with this many jobs, especially if changing priorities on several hundred jobs at a time.

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