Does anyone know how to make sanic run in a serverless infrastructure like AWS Lambda?
Right now you would have to follow this: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html
Seriously? Does sanic have a handle function that accepts 2 parameters?
No I was just kidding.
Thank goodness. I thought somebody has been able to make it work with Zappa
I think that Sanic isn't WSGI?
You may need this: https://github.com/ashleysommer/sanic-dispatcher
@Miserlou You would be correct in assuming that Sanic does not have WSGI compatibility
And sanic-dispatcher does look awesome!
If anybody wants to try it,
I think
https://github.com/fifthecho/zappa-sanic
plus
https://github.com/Miserlou/Zappa/issues/798#issuecomment-299952245
should work
I would like to point out that using Sanic with lambda is kinda pointless as it will invoke a new server for each request defeating Sanic's purpose.
I've found that using Flask with Zappa's beautiful async decorator https://blog.zappa.io/posts/zappa-introduces-seamless-asynchronous-task-execution is more than enough (it will simply call a new lambda instance)
Just a note, that's not how AWS Lambda works. AWS Lambda uses something like docker and pauses the instance when there are no pending requests or response. So it is indeed possible to have a long-lived server in AWS Lambda.
Just a note, that's not how AWS Lambda works. AWS Lambda uses something like docker and pauses the instance when there are no pending requests or response. So it is indeed possible to have a long-lived server in AWS Lambda.
It pauses but effectively dies, it won't route two requests to the same instance
Most helpful comment
If anybody wants to try it,
I think
https://github.com/fifthecho/zappa-sanic
plus
https://github.com/Miserlou/Zappa/issues/798#issuecomment-299952245
should work