-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Improve memory footprint of queue workers #32
Comments
The places in the code to start looking at this are zerver/worker/queue_processors.py and zerver/management/commands/process_queue.py. To start with getting this working in the development environment, you can patch tools/run-dev.py to run things with your new tooling. |
Would be very cool to make this multithreaded, the 4GB memory requirement for a production server is very high. |
#367 will make the Zulip workers multithreaded in the development environment; there will be a bit more work to do this in production since we'll probably want to offer both configuration options... |
@timabbott cool! I'm not sure why anyone would want non-multithreaded workers, or is it temporarily until multithreading is stable? |
Well there are two considerations:
Both of these seem like things that shouldn't be a problem in the long term, but likely are important enough that I'd imagine we want to support both options for a transitional period... |
Totally agree about the transitional period. |
This change drops the memory used for Python processes run by Zulip in development from about 1GB to 300MB on my laptop. On the front of safety, http://pika.readthedocs.org/en/latest/faq.html explains "Pika does not have any notion of threading in the code. If you want to use Pika with threading, make sure you have a Pika connection per thread, created in that thread. It is not safe to share one Pika connection across threads.". Since this code only connects to rabbitmq inside the individual threads, I believe this should be safe. Progress towards zulip#32.
…es API. The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurence in a topic. This list is passed back in the `topic_links` parameter of the get-messages API response. topic_links before vs now: before: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links before vs now: before: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links before vs now: before: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Also, adjusted the recipient_row template to use the url parameter of the topic_links to set as the href. Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Also, adjusted the recipient_row template to use the url parameter of the topic_links to set as the href. Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Also, adjusted the recipient_row template to use the url parameter of the topic_links to set as the href. Tests amended.
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Tests amended. Fixes: zulip#17109
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Tests amended. Fixes: zulip#17109
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Tests amended. Fixes: zulip#17109
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Tests amended. Fixes: zulip#17109
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com", 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Tests amended. Fixes: zulip#17109
The linkifier code now includes both the shortened text and the expanded URL, sorted by the order of the occurrence in a topic. This list is passed back in the `topic_links` parameter of the /messages and the /events APIs. topic_links earlier vs now: earlier: ['https://www.google.com', 'https://github.com/zulip/zulip/32'] now: [{'url': 'https://www.google.com', 'text': 'https://www.google/com}, {'url': 'https://github.com/zulip/zulip/32', 'text': 'zulip#32'}] Similarly, the topic_links local echo logic in the frontend now returns back an object. Fixes: zulip#17109.
Since it seems there's a good amount of interest in running Zulip in smaller environments, it's worth doing a bit of optimization on the Zulip memory footprint. I think this will also be pretty valuable for running the Zulip development environment on a laptop.
I think probably the simplest version of this implementation would be a way to run all the queue workers in a single process that just watches all the queues; that should be great for development and smaller servers, and easy to make work (no need to even make it multithreaded).
Part 2 would be to make that multithreaded.
The text was updated successfully, but these errors were encountered: