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

Reduce the size of cron_job.py instance. #221

Closed
Fillll opened this issue Sep 11, 2022 · 3 comments
Closed

Reduce the size of cron_job.py instance. #221

Fillll opened this issue Sep 11, 2022 · 3 comments
Assignees

Comments

@Fillll
Copy link
Owner

Fillll commented Sep 11, 2022

Now it's ~40MB. Which consumes too much memory. Should be much less.

@lgyanf
Copy link
Contributor

lgyanf commented Sep 11, 2022

Creating a new Python process will still have a memory footprint measured in tens of megabytes. We can try to reduce that footprint by switching to forking (as in os.fork()) and rely on COW memory, but it would still be hard to control memory usage.

As an alternative, I can suggest switching to concurrent.futures module with a ProcessPoolExecutor or a ThreadPoolExecutor, which will allow us to control how many tasks can be executed simultaneously.

Later we can also switch to async/await statements to reduce the footprint even more.

@Fillll would love to hear your feedback on this :)

@Fillll
Copy link
Owner Author

Fillll commented Sep 11, 2022

Sounds like concurrent.futures could be a good solution, at least in short term, as we are losing some postings now.

Just to be on the same page. We want to fit 999MB instance with all python processes and DB instances on the same machine.

@lgyanf, please go ahead and create PR. Thank you!

@Fillll
Copy link
Owner Author

Fillll commented Jan 29, 2024

Since merged, consider it done.

@Fillll Fillll closed this as completed Jan 29, 2024
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

2 participants