Sanic: AWS Lambda Support

Created on 3 May 2017  路  11Comments  路  Source: sanic-org/sanic

Does anyone know how to make sanic run in a serverless infrastructure like AWS Lambda?

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

All 11 comments

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

Was this page helpful?
0 / 5 - 0 ratings