0

I got Flask application written in python 3.6.

On registration there is created user and synchronization with external service is done (takes ~5s).

class Register(Resource):

    def post(self):
        submitted_data = flask.request.get_json(force=True)
        user = User.register(submitted_data)

        # long-running API calls
        user.synchronize_with_external_service()

        return {}, 201

User is SQLALchemy model. During synchronize_with_external_service external service is called and some fields in db are updated. Due to this synchronization taking long time I would like to do it asynchronously and response user immediately. I thought about celery, asyncio or multi-threading to do it, but I would like to know which option is best.

Application is setup on AWS Elasticbean (load balancing, 2 instances, multi-docker).

Blejwi
  • 1,005
  • 2
  • 10
  • 25
  • go for celery its best – Argus Malware Nov 08 '17 at 11:42
  • I got my application setup on AWS, elasticbean with load balancer (2 instances), how should I setup celery here? Use separate EC2 instance to do this? – Blejwi Nov 08 '17 at 11:50
  • You might find it helpful [How do you run a worker with AWS Elastic Beanstalk?](https://stackoverflow.com/questions/14761468/how-do-you-run-a-worker-with-aws-elastic-beanstalk) – ryche Nov 08 '17 at 14:39

0 Answers0