AV-Portal 3.23.3 (4dfb8a34932102951b25870966c61d06d6b97156)

Serverless Django with Zappa

Video in TIB AV-Portal: Serverless Django with Zappa

Formal Metadata

Serverless Django with Zappa
Title of Series
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Which platforms will support my app? What OS should I use? What WSGI server should I use? How much memory and CPU do I need? Zappa, a framework for running serverless WSGI applications on top of AWS Lambda, can help address these and other questions around application deployment. With some configuration (as code), Zappa can get you up and running quickly, letting you focus on developing the application instead of the infrastructure. In this talk we’ll go through some of these kinds of questions to see how they might be answered in traditional solutions and then see how Zappa handles them. We’ll also talk about a few specific configuration options for handling SSL certificates and running Django commands on the Zappa-deployed application.
Server (computing) Pi Software developer Web-Designer Data storage device Electronic mailing list Game theory XML Metropolitan area network Computing platform Twitter
Point (geometry) Server (computing) Server (computing) Software developer Gender Bit Cartesian coordinate system Mereology Graph coloring Web service Latent heat Core dump Software framework Resultant
Web page Dataflow Server (computing) Dynamical system Group action Functional (mathematics) Concurrency (computer science) Computer file Structural load Dependent and independent variables Code Multiplication sign Translation (relic) Parameter (computer programming) Mereology Public key certificate Product (business) Web 2.0 Hypermedia Dependent and independent variables Server (computing) Structural load Chemical equation Database Bit Cartesian coordinate system Word Data management Process (computing) Video game Website Object (grammar) Quicksort Cycle (graph theory) Lambda calculus
Gateway (telecommunications) Scheduling (computing) Concurrency (computer science) Run time (program lifecycle phase) Structural load Code State of matter View (database) Multiplication sign Execution unit Code division multiple access Set (mathematics) Database Real-time operating system Coma Berenices Function (mathematics) Public key certificate Uniform resource locator Data management Optical disc drive Different (Kate Ryan album) Computer configuration Single-precision floating-point format Endliche Modelltheorie Lambda calculus Arm Public key certificate Broadcast programming Relational database Concurrency (computer science) Structural load Computer file Moment (mathematics) Data storage device Flow separation Type theory Data management Fluid statics Computer configuration Order (biology) Pattern language Quicksort Cycle (graph theory) Task (computing) Electric generator Point (geometry) Functional (mathematics) Server (computing) Identifiability Computer file Observational study Sequel Translation (relic) Similarity (geometry) Device driver Directory service Data storage device Scalability Number Product (business) Time domain Profil (magazine) String (computer science) Design of experiments Task (computing) Domain name Installation art Dependent and independent variables Gateway (telecommunications) Server (computing) Projective plane Code Database Device driver Cartesian coordinate system Limit (category theory) Integrated development environment Function (mathematics) Point cloud Video game Routing Lambda calculus
Scripting language Scripting language Hypermedia Computer file Hypermedia Computer configuration Computer file Ideal (ethics) Directory service Endliche Modelltheorie Task (computing) Number
Latent heat Scripting language Information Building Gender Equaliser (mathematics) Demo (music) Physical law Cartesian coordinate system Mereology Product (business)
Point (geometry) Complex (psychology) Functional (mathematics) Server (computing) Presentation of a group Sequel Divisor Computer file Multiplication sign Control flow Set (mathematics) Likelihood function 2 (number) Product (business) Medical imaging Goodness of fit Term (mathematics) Hypermedia Computer configuration Different (Kate Ryan album) Energy level Shift operator Scaling (geometry) Electric generator Relational database Structural load Cellular automaton Data storage device Electronic mailing list Coma Berenices Database Instance (computer science) Cartesian coordinate system Chain Website Iteration Quicksort Freeware Library (computing)
Internet service provider Data type
in the in the world. you can see.
a. so thank you she said man's game and i am a web developer sikka. you may notice from j. store dot org it's an academic research platform. and on twitter i'm easy as pie fun and get have been dane h. so feel free to connect. and i am here today to talk to you while data. but will not not this is as well although he wants to talk all on his own many talks perhaps but that nonetheless and specifically how we can do server list django with apple and specifically i mean this data and serve.
framework written by a guy named rich jones. and what it really does is let you do serve realists eight of us to points for python applications and so during this talk and going to kind of emphasize the these pieces here in bold colors. so what we're going to do is talk about each of those in a little bit of details will talk about servers what a server really is and what the last part of service really means. and then some specifics about amazon web services and how you go about actually deplane application there so first let's talk a little bit about servers.
they are at their core a thing that a user can make a request to and receive a response from as a result and so many of you being gender developers are probably intimately familiar with this idea and but what really happens and how to.
how do we achieve that work flow along the way. see how the server and one request comes in it typically gets handled at first by a web server which knows how to speak h t t p. and then that pass it along to something like a unicorn which is a way to translate h.t.t.p. request into something that python can understand and ultimately it will end up at it. you're doing the application and and there is there some additional things that you'll probably be using if you're doing any kind of dynamic application. you probably need to talk to a database you'll probably need static assets to style your pages and you probably want a certificate of some kind if you want to be working a very g.p.s. and. and as you get more traffic to your application you want to be able to handle more concurrent requests so you'll start making more processes for your jingo application in each of those can handle request at a time and then when your server inevitably can't handle the load and falls over you decide maybe yield. make several of those servers and put them behind a little balance or. so you started he starts killing horizontally and to handle all this traffic and that's fine. but if you like me and don't really have time to do a lot of automation of your your develop some things like that managing all of the servers can get kind of tedious and kind of frustrating and so how do we do how do we do less.
i like ron swanson there has to be a better way and we want to use free ourselves of the earth the burden of all this machinery and so at what less really means to me in in service which is the sort of marketing buzz word is that you do less management and you do. this sort of filling with all of these moving parts and try to find a way to more easily manage all these things in an automated fashion an abstract some of those things so you don't have to see the details every day. and so this again is is what server might look like a and we want to find a way to basically take these different pieces that are on the server and get them off of the server so that we don't have to deal with them anymore or can deal with them in a better way. and so would start with certain. how many of you are familiar with watson product. great that's like half of your so it essentially lets you much more easily. the set up a certain and and serve your website over https to the world and was on also has an answer to this called amazon certificate manager so for the sake of argument let's i was off load that to the amazon certificate manager this way we can just easily create a certificate in the. in the consul and apply it to the resources that we want that certificate to be on and so that's the sort of locked in. and now that is off of our server in the next thing is those static assets on you might call it could be the media that your users are uploading as well so right now you my story goes on your server at least temporarily and when they win they are uploaded or when you're collect. static during your deployment and but we can store those in amazonas well has a thing called simple sword service on and you can refer to those those different files by their by their object basically in history and let's look at it and the last. it's the last remaining pieces are really the parts that are important to the request response life cycle that leads from h t t p request down to python translation down to change so how do we get rid of that stuff that seems kind of tricky i'm so. one way we could imagine doing this is with some other amazon tools on some were taking away the job of routing from engine x. and using instead amazon's a.p.i. date way and and were taking the job of translating requests from h.t.t.p. to python. on away and using landed to do that so many of you have heard of lambda ok that's like most of you and so that's great. lambda is amazon's functions as a service essentially. and what they do is let you respond to requests and by executing some function and it would be great because they would be great if we could use django as the underlying function for this on. and effectively get rid of our server and so as you can see certain from this last transition we kind of freedom or selves of of the need for this server wrapping all of our code so how how do we get there. and how it more importantly how do we respond to it more activity in our application and so what's let's talk a little bit about what the details are under the hood in aid of us and so imagine we're creating a website where we can post pictures of.
of poppies all the best poppers. and what we need for our first ticket is to create this certificate in the amazon certificate manager and then what that lets us do his reference that certificate with an amazon resource number are and aren't so that long string the sea is the. identifier basically for that certain by the way best overstock dot com still available as usual by that. and then for are static assets and we need of a bucket to store those in in just three and so we're going to tell are going tells apple how to wear to put his stuff i'm by referencing that bucket name is well and. the next piece sort of the crux of it is that we need to put our django application into lambda and there's sort of this rapper around it that does that was the translation for us and then landed can handle all of that horizontal scaling that we talked about earlier. or so. once we once were able to do that we're sort of humphrey and and with a p i get way we can manage our different environments on and and route requests for different domains two different sets of applications. and so to recap it ends on certificate manager for s.s. all sorts and s three first semifinal storage and if you're feeling really ambitious and you can put cloud front in front of it to get a global he distributed said of of static files to speed up delivery to users and then. lambda for our request workers and the a.p.i. gateway to route requests to different applications. the next step is the point.
hopefully you can do it the first time and so the way a way that we do this with data is basically to in. july's are configuration. and set up the details in ours at the settings so how do we do this. in order to get your application set up as apple. like here i've just basically started with the ginkgo start project best poppers and so you have your single application model that package rather with your settings in your old patterns in your was due to high as well as your managed up high and. a you also need your eight of us credentials listed. and the way i prefer to do this is to have a different profile for each of my projects and even if they end up using a similar set of credentials so once you have those two things in place you can just pick installs apple and runs at the unit. and what that's going to do is detect your application type so it's not actually just jane doe that is supported it's really any was yet occasion and even some on was getting patients if a firmer correctly and then it will create that us three bucket so they can upload artifacts for your application and then it will. create this is after setting studies on file. and i first got to look probably something like this so you have a staging environment may be a production environment on and each one will have the u.s. region that is deployed you and then it will automatically figure out your django settings model. and the profile name is referring to that of the us credentials profile and then the project name is your django project and s three but it is that bucket name that we talked about earlier. so then now that you've got all this configuration place i sort of ready to do your first appointment its it's pretty much that easy and so you runs out to deploy staging and staging is the name of that environment from your set that from years after settings. states on and what they'll do is. well i want i won't make you read all of this could hear or this output year but what happens is that it will freeze your python requirements along with all of your application code into a single zip file and then it will upload that zip file two s three into that bucket and then it will create a p.r. gateway routes for you. and it will create land the functions that ultimately point to the ginkgo view code that you need to execute in response to requests and the hook a.p.i. gateway to those linda functions and importantly it prints out the u.r.l. you can visit your application that at the end. some long randomly generated string of characters followed by this execute a.p.i. u.s. east one or whatever region year in amazonia of us dot com and then slashed your environment. and updating your application is quite similar again it's its downloading over dependencies packaging them up a zip uploading that s three and then since or updating your application it will update the land a and. redeployed a p i get way and then i give you the ural to visit that again. so the next step after this is getting are certain order an end fortunately that is very easy to so once you've created a certificate an amazon certificate manager but you can take that aren't that it of us resource manager or resource number string. and specify it in your environment as the certificate arm and then tell of the domain that you want to certify and then you just runs at a certified state and that will certify the staging domain you specified using the search specified. and then through this you also get a large storage and tailing as you can see what's happening in your application in real time as well as persistent as long as for later use you also get management commands and even the ability to run rompuy. on against your land up against your environment where the land to lives. and as as you should know from when do you get out of scaling to meet your request load on some points there though are to watch out for concurrency and cold start time on you can read more about that as a there's a good article i could point to later on but essentially just if you're trying to serve a very fast. requests on you may want to look into that first and importantly you'll probably have a way lower it of us bill and because you don't have servers running when they're not serving any requests so a request comes in it is managed by that way. the function and as soon as that response is sent that lambda goes away and you only pay for the execution time of that requests life cycle. and the couple of odds and ends to are like surrealist database options i was on did release or service recently that's their my sequel compatible product. and it's so it's a manage solution but the cost is really comparable to any of their other database lucian is at the moment so that wouldn't necessarily be a price came there although you might still like the a of the managed solution facet of it there's also dynamo db but that's no single solution and i don't know. no at least at the time of writing this talk of any of that of any production ready drivers for django for using the mo d. b.. there are a couple of other options out there that are not necessarily django specific on that are also not relational databases but it might still persists data for you in a way that's that's useful to you and them and then you can also run a synchronous task so zappa can actually run functions from your coat. would on a schedule if you like and you can specify things in like a cross in tax and say every four hours please run this thing and if you wanted to do celery workers and things like that you did you'd have to look into that yourself because that's not to mention familiar with but you. it also split your application in two separate land as if you like if you really need a sort of separate asynchronous behavior and long running them as aren't super well supported although i did see that it of us recently up to the execution limit to fifteen minutes and i think it was previously five. so you've got trouble the time to do what you need to do. so some some tips are that you would probably want to exploit most of your new files node models is huge. i mean it's this i don't you don't want to ship more than you have to do so.
like no models if you use by charm your died he a folder and if you are uploading media files locally and you probably want to exclude that directory to it just reduces the pile size so i consider it faster and ship it faster when you go to deploy. and the other major to i have is that you should automated process and.
you and there's there's a number of options out there a lot of people use fabric and i personally use and p.m. scripts and because i'm are using were packed for my static assets on so i have a few scripts already my packages on look something like this.
this law stuff but if you if you want to knowing more about this so i'm happy to like show you this file in and talk about all the parts of it in the hall on him and what essentially allows me to do is deploy my gender application by just running and p.m. run deploy dashed s. stage equals. production and so that's basically all have and if you'd like to like i said to see more of us or talk about an anything specific as you live demo and happy to do that in his my contact info again.
thanks. i think with the presentation what is something hoskins iterations for performance so how would you can hear you paid for every occasion. of the land of function as a small price individually how that come here to have known easy to distance yet good question and so i was previously running for applications on an easy to instance and spending something around fifty dollars a month i don't remember the d.c. to. for instance size that i was using but i'm essentially paying zero dollars per month now and amazon gives you something like three and a half million invocations free per month. so if you're if you're at sort of a hobby level amount of traffic that i would say there's almost no likelihood that it's going to be more expensive and they're certainly going to be a break even point there if you're if you're getting so many requests that your land is essentially running all the time i could definitely see that that might. and perhaps even out run your easy to cost and so definitely consideration the question i'm not given ideas that are also due on when you say he goes to asses goes to extra he does that leave hundred ninety two when you can ask does to us. many of you have to do some conclusions and their yeah good question so. is apple will not do that for you and there are a couple of really good solutions out there for putting your static assets invested readers a library called django storage is on and it just takes a a few small pieces of configuration like adding some settings to your settings up high. in may be creating the buckets yourself initially on but you can essentially collector set files and upload your media files directly tested using during a storage is so that's why i'm doing it currently images and service database options how does that compare to like a standard r.b.s. instance can you. to clarify your question i mention that the aurora and finally been under surveillance data bases in the talks as one of that money is in special about that for using and with landon as compared to an r.b.s. post presence i see that mean that are again is like my sequel. compatible so if you are using my sequel you can probably switch turo pretty easily the you have to migrate your data and stuff obviously but. i think villa server lists aspect of their or product is really just them saying we haven't managed solution for this instead of you having to go and click can create an r.b.s. instance yourself and run back ups and make sure that its handling the load that you're getting so it also manages that. or is on a scaling and secure if you're having a lot of database reads little scale out for you but in terms of sort of how you interact with the database for at least i don't imagine there's a difference if you into dynamo t.v. or some other a non relational database that would be a more significant shift. said answer questions. the things we talked on can you tell us about the latency heard by some are you were many factors that chains are lazy depending on the complexity of your slugger outsize yet it's not something i've dealt super far into to be honest but anecdotally on a totally cold start of websites. been receiving my copy levels of traffic but they take maybe a couple seconds to load if i haven't hit them in a while and then some the subsequent requests are essentially is instantaneous as far as i can i can feel i could show you just real quick like me. you can hear you. the church. sorry multiple dust us. well i'm sure i'm happy to show you a hallway but and yet it's quickly. there are about adult time the cell much pain makes.