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

Remove custom celery routing and exchange #2193

Merged
merged 1 commit into from
Aug 25, 2017

Conversation

mmcfarland
Copy link
Contributor

@mmcfarland mmcfarland commented Aug 25, 2017

Overview

Due to the implementation of async SJS requests, we established a mechanism for directly establishing routes that would stay on a single worker. This led to complex code and also high latency when we pinged each worker to determine if they were available. With recent changes removing SJS in favor of a synchronous geoprocessing call, we can now cull these custom routes and exchanges, both simplifying the code and increasing the speed of submitting a new job.

Connects #2117

Fixes #1903
Fixes #1894
Fixes #1535

Notes

This reduces the HTTP response time for all celery submit endpoints considerably. Locally, they return in ~250ms, as opposed to seconds on staging/production.

Testing Instructions

First round of testing is to ensure that all geoprocessing tasks work (except Mapshed which is still being refactored - however, the mapshed jobs should still be submitted correctly, the streams will fail).

  • Notice that all async submissions (eg, /land, /soil, /tr55, /rwd, etc) respond in milliseconds and not seconds

Second round of testing is to make sure that the work is still adequately shared between workers and that stacks of another color don't process jobs submitted for another stack color.

Follow these instructions sequentially, as the steps build on each other.

Test multiple workers
  1. ./scripts/debugcelery.sh to launch a worker thread on the Black stack
  2. Open an additional terminal and launch another worker on the Black stack:
vagrant ssh worker -c "cd /opt/app/ && envdir /etc/mmw.d/env celery -A 'mmw.celery:app' worker --autoreload -l debug -n debug2@%n"

Notice the default key is task.Black in the output

--- ***** ----- [queues]
 -------------- .> Black            exchange=celery(direct) key=task.Black
  1. Continue to use the app to submit analyze and tr55 jobs, they should be spread to both workers.
Test multiple stack colors
  1. Open a third terminal, and ssh onto the worker: vagrant ssh worker
  2. Edit the env file for stack color, change Black -> Blue
    sudo vim /etc/mmw.d/env/MMW_STACK_COLOR
  3. In /opt/app, launch a third celery worker, this one will start as if on a Blue stack.
envdir /etc/mmw.d/env celery -A 'mmw.celery:app' worker --autoreload -l debug -n debug3@%n

Notice the default key is task.Blue in the output

--- ***** ----- [queues]
 -------------- .> Blue             exchange=celery(direct) key=task.Blue
  1. Continue to submit jobs, only the 2 Black Stack workers should be processing them, blue should not receive any.
Test switching stack task submission
  1. Open and edit settings_base.py and set STACK_COLOR = 'Blue'
  2. Submit jobs and see that only the Blue worker processes them.
  3. Revert your changes to settings_base.py and /etc/mmw.d/env/MMW_STACK_COLOR

Due to the implementation of async SJS requests, we established a
mechninism for directly establishing routes that would stay on a single
worker.  This led to complex code and also high latency when we pinged
each worker to determine if they were available.  With recent changes
removing SJS in favor of a synchronous geoprocessing call, we can now
cull these custom routes and exchanges, both simplifying the code and
increasing the speed of submitting a new job.
@rajadain
Copy link
Member

Taking a look now.

Copy link
Member

@rajadain rajadain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1!! This works exceedingly well, leading to a more noticeable speedup to the end user than the GeoTrellis upgrade. Also very glad for the simpler code and easier routing. This is a solid win. 🎈

Great job on the testing instructions too. Tested on a single worker, multiple workers, multiple workers of different colors, and changing the API's preferred stack color on the fly. Messages were routed quickly and correctly.

@rajadain rajadain assigned mmcfarland and unassigned rajadain Aug 25, 2017
@mmcfarland
Copy link
Contributor Author

Great - thanks for that feedback.

@mmcfarland mmcfarland merged commit 8577f11 into feature/collections-api Aug 25, 2017
@mmcfarland mmcfarland deleted the mjm/celery-crunch branch August 25, 2017 21:15
@rajadain rajadain mentioned this pull request Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants