Merken

Going Serverless

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
thank you that and that you can do that and so there it's time to get started here my name's jeremy green and I'm talking about going service and so what we need about what a server listening that's kind of a weird turn around the idea is that we want to deploy a web applications without servers I so I'm guy land here and a little bit a mind-reading I that some of you are a
thinking a very particular thing right now you think and serverless really come if a server
something you need servers right so it'll make you feel better we can think of it like this or
call it serverless with with little air quotes so the the goal here is that the and there are servers involved but we don't think about what we want to think about our code as code and not worry about the particulars of the infrastructure that's being deployed to and if you've deployed to something like a roku you already kind of know how this works you know I broke a you're not really thinking about instances you might be thinking about your dyno size uh that kind of thing but you're not thinking about the physical infrastructure that it's running you just going your stuff and pushing up and letting the group to worry about what machines does it go on what instances does it go on that stuff so that's where we get to and in
particular in this talk we talk about serverless will be talking about the service framework on
the serverless framework is a framework for building web mobile and Internet of Things applications exclusively on AWS land API gateway and there are other related services
so will but more mind-reading here that if you have you noticed that word exclusively on the last slide and you're probably thinking this the vendor lock-in the so
that the kinds of interlocking are pretty obvious I'm not review really gonna get into on so you know why would you sign up for this kind of interlocking the the most compelling reason is
ops Amazon is better ups than you will ever be if you disagree with me on that please talk to me and we can put together a nice fact insulting proposal to help Amazon be better but that's unlikely if so this is especially true for an application developer and not and operations engineer another 1 scale
they have data centers all over the world by deploying into their infrastructure you can take advantage of their scale with very little work another compelling reasons money especially
when you compare the salary of operations engineers deploying and sons and structure can be very cost-effective so just a little bit about me my name's jeremy
green I'm a console needs an author and I run a couple sass businesses are you can find me on the tweets that Jagger drama uh there's my e-mails sent me an e-mail if you like but
the independent insulting manuals a book that I read recently co-authored a remarked that I 0 is 1 of my ancestors and also into drumming photography and brings the likely those things when talk about and we give a shout out to my
client clicked funds they've supported me in this talk working within this right got and all the surrealist stuff they help me get the Conference of they've been very supportive I really appreciate them of so I don't get too deep into the weeds of what they do but I think that is very technical diagram of their
infrastructure that act so enough silliness
but 1st talk about the pieces that were really dealing with were kind I going to be using some building blocks that we're going to build up into bigger applications so the 1st piece is
AWS land this is basically function execution on demand I think about like her roku for single functions you give them 1 little function tell them how you want to be run and then you can call that function either via the API or they have a service called API gateway
which allows this is kind like routing is a service so this allows you to set up points and then when somebody hits that point you can wrap that request to be handled by land are you might use dynamo DB
historian some data or you might use
our RTS for any of the other services that they offer and in cloud
formation is a kind of infrastructure is code this is a way that you can describe have assets that you need in your infrastructure like a dynamo table or an RTS instance you can keep that description in your source code repository and then you can push at Amazon and ask them to deploy this stuff for you so this makes it really easy to have a look like a staging environment that you can duplicate in the production of and you know that you're using the same stuff across all your we put all
this together you're and end up with something that looks kind like this using multiple Amazon Services to rout of requests around and they give you a lot of tools for you can
do this you can get in there you I see a list of all your land the functions are you can
browse the repository of demo code that shows the various applications various things that you might do
that when you go to create a when the function you can set a bunch of configu variables like how much memory should have was the time out and you can hook up to an API and
point you can add that source from some other place but if you do all this for a very long your
start thinking seriously my coding in the browser as is this what would come down to on
and if you do that long enough you're going to go through cycles of like this you feel a little bit unamused about at the nearest star to get worried about the number of things that can possibly go wrong when somebody's just making changes in a browser and not many things source code and if you keep down that path you can get very angry so don't do this but this is 1 server was
framework comes in the service framework allows you to manage land the API gateway and other cloud formation services via code instead of the group and you can find the docks not start surrealist outcome it's all pretty good I should go ahead and say that this is a very young project and is moving very quickly on so everything that I'm gonna talk about and show you in details could change by this afternoon but probably not but just be 1 it's very young so when you get started with
serverless in the 1st step is you want create a new AWS account you don't when use the 1 that you already have up and running for all your production stuff and the main reason for this is that the serverless documentation at this point advocates that for getting started you should create basically an admins Super User that can do anything and everything In Europe structure and so that's kind of a security risk you don't want that profile to you know get in the wrong hands or something to start shutting down your production instances are deleting an S 3 bucket or something like that so really seriously just start with a new account and then as as you figured out what you actually want to deploy in Production take time to understand the permission model and do it correctly so the star serverless it's an NP
model and my apologies to use URLs and tender love for having to talk about node but you know I I and fully on board with making Ruby great again so will look at how we can do little while and so once you install it you can do at serverless project create the seal i gives you a nice shorter version of serverless you have to type up the whole thing you can say SLS if you want to on and then the 1st thing you're going to see is some sweet ASCII arts that I know it's good right on so this goes 1st step and you through the process of creating a new project it's nasty name I it's been asking for a stage and a stage in the surrealist terminology is a lot like an environment like if you're used to development and staging in production environments it's almost exactly the same thing it's just call a stage yes i it's nasty what profile you wanna use if you training you wanna use 1 that's already there and then it's going to ask you what region you're going wanna deployers stuff after the little bit of stuff that's going to finally tell you OK your projects ready and some things have been played a cloud formation if you go into the directory that's been created for this new projects but it see a tree that looks about like this and all the stuff that you're seeing is in the rails world is going to be stuff like in Fig . are you of you know configs slash application be a bunch of just yeah bootstrap boilerplate that needs to be there to get the thing to run but that you probably don't really care about until you need to make it do something that it doesn't do out of the box so or not in a really messed with looking at any of that stuff so
let's build something on but before and build something the question is the what we built and
so build something that actually does something not just a stupid Hello world applications so and we do this but I mean
it there's an empty a model for right so that means it must be useful enough to be of service
so for thing induced serverless function creates give it the name that we won't left that i it's going ask you select a 1 time in this case we're gonna go ahead and use node for 3 and then it's going ask if you wanna create an API and point for an event or just a function on itself and in this case were actually create and point so that it's easy to get the point if we look in the directory that's creative force we have 3 files event but Jason is a and basically reset upsampled later that year function has been used and we're not JS is the function itself that you're right and as function that Jason is some configuration for the land for the end point for any other resources that you need so this point it's already
ready we can ship and this is part of the workflow that you're really use with serverless you can exactly Rhinelander an API gateway on your local development box and so you're going to be constantly shipping stuff to Amazon in the dead stage testing out there and then when you're ready you can promote it into here like staging stage or production stage where so the to deploy you can
use serverless dashed employ a dash short for dashboard it's going give you something like this more sweet ASCII art and then a list of all the things that you can deploy here the selected that I want to put the function and the end point and then hit the deployed it goes and starts doing stuff and it tells you that it's to put the functions into the dev stage and then it's deployed the end point and at that stage and then at the very bottom there you'll see gives you a URL that you can hit where you can see your function running through the API and why so if you have that you see something
that looks like this it's so it returns adjacent blob that has a message and messages go service you member function executes successfully so let's look at what is the code
look like that that generated this so
this is the default handler that surrealist generates for you very very simple and it exports a hammer function the function has 3 arguments and event the context and call back and then for the default 1 it's just calling the back with the payload that we want to deliver so the event the event is just a adjacent object full data this is something that you as the developer or whoever's calling this function is gonna put together these are the inputs that go into the function that you want to have worked on to create your outputs the other context is an object as provided by the Land Infrastructure this gives you some details about who's calling 1 of the most important things is get remaining time in milliseconds so this allows you to do some things that are kind of long running as long you can pause them so you could you know be iterating through a bunch of records and then be checking this to see how much longer you have until your land forcibly killed and then you could you know right to the database here is the last 1 that we did on this run and then Q and other now you can also get some stuff about the identity of using some of the AWS authorization methods and and then if it's being a call from a mobile device you can get some client context about what's device with the operating system is running that stuff and so then finally of a callback function this is also handed in from the land infrastructure of the signature of it is that you call the callback passing in an error and then the data and of this is fairly standard node Kullback structure but if you need to only return an error you can just return air but if you need a return actual data he she returned Nolde for the error and then returned the it so now let's get this this function actually doing something so if we go into the left that directory and we can do in the net and what's happening here is were creating a local node marginals directory and package that Jason so that we can have an additional libraries that we want a ship with our function everything that's in your function directory is going to be shipped to Amazon when you do serverless dashed deployed and then we can install at that and save it so that it gets added to our practice yeah so then we can start updating the handler so the 1st thing we wanna do is require the left that but this is happening outside of the hammer instead of inside the handler because everything outside the handler is run once when lim when Amazon 1st launches and tries to run your lemma for the 1st time so anything that's the along war like a is going to take some time and is not part of the actual processing your inputs to generate outputs you wanna do that outside this is set up stuff the so the next thing we can do is I declare coupled variables were we're going to pull of data out of the event that is passed on and they were going to create a padded string by calling the left pad function that we get from that and PM model and the morning to construct a payload that is was just returned the pattern string as adjacent object and finally water were call the back with no was the 1st argument because word we didn't run into an error and then the payload as the 2nd but
we also need to make some adjustments to as function this is all all what you see right now is automatically generated by the surrealist this is where you can tell why and the how much memory you need for your function run you can also see what the timeout is that kind of stuff and and the handler line there you're giving it the name of the handler that should be invoked and that is constructed by the name of the file with it lives in and then the name of the the function is being exported so in this case and by default it's to be handed out handler because it generates a file called hammered out JS and then inside of that it's exporting handler as a function but this stuff is also auto-generated when you go to create your your function I told it that I wanted to create an point so it generated says there's a path coal left and so that means that once you hit the URL of API Gate gateway generates for you you go to that slashed left pad that's here in invoke this function via the gateway I think know you're gonna be doing it the again you can use all the standard HTTP methods here the GET PUT POST delete even options and then and then there's request template and by default the request template is black and this is basically how you tell API gateway how to generate the event that you want based on the HTTP requests that comes in because you're when the function doesn't know anything about http it's not it's not a name of a ship to be function that just gets an event object then care how that of an object is created a white so you need to tell API gateway how to d construct an HTTP request and create an event that can be used by your function so in order to do that you can add a couple lines that look like this so we're saying is that we want to create an event with 2 properties one's called string and one's called padding and string event should come from the input parameters of the HTTP request and it should be the prom called strength and then the same thing for the patterns it
so what you may all those changes you can dash employ again and again it's going to give you a a URL where you can have it and so then if you call that URL with the you with a couple of Quadram's that look like this string and padding is to return a pattern string you know that about the 10 spaces that we want to be yeah so how do we test something like this like I mentioned the the function is just a function so it's really pretty easy to test you test it just like you would any other vanilla function you don't need to worry about the land of stuff you can er API gateway stuff you can just as the function itself so we can install Moeka to drive the test and then we can install something like Scheidegger nice assertions and then make it look bad slash test and we require tried require the Hamburg file that we're that is under test in this function but as so then we can just create is basically a mock event that we're gonna pass into the the function in order to test it other context we're not using any the context that Landis applies to assist in this case so we can make an empty object and then for the call back this is where we can do assertions on the return value that we get out of land the so the we just make a function that has the same signature as the back that lambda provides for us and then once that's called weak at that point we can say that we expect there to be no because we don't expect to get anything and then we can say that we at that we expect the response that pattern string to equal the value that we expect to be returned based on what's in the test event at the so then once you've got that on the employer that test violent place you can just call Moeka on the test and it's going to run it show you that it's return the right thing and that's been successful so what about really
mean that's kind of a bummer that Ruby's not supported right out of box but we can do some things to get it to run I'm what what I'm going to show you here is all that the proof of concept stage it's not production-ready if you want to do Ruby and lambda you you're gonna wanna hard metal that make it lot will more resilient to errors of crashes that kind of thing I so what I
did here was serverless function creates a and then called it in Ruby Hello world I added 2 additional files into that directory 1 is Ruby script that's gonna run so Ruby code and the other 1 is the M Ruby executable itself I used in Ruby on this because I found proof of concept that Nick carancho put together previously that was using in Ruby so I knew was compiled and would run on land and AWS does publish what the operating system and 8 AMI image that they are or running the land on so if you do need to compile self you can fire proceed to instance compiled and stuff there and then add that binary into Europe package you probably don't want to make sure that you statically link everything because they don't provide a whole lot of stuff in the full image so since
landed doesn't support Ruby right out of the gate we can have to get it to work in a backhanded way we have to write it a node-based handler that then shells out to Ruby to let it do what it needs to do so to make that work used Spong library I'm sorry the child process the library and in specific the spawn functions but to create a process a call spawned telling it that we will use the in Ruby executable that's In the project directory and that we want to run handler and that we that it should pass in adjacent stringified version of the event this lets the Ruby script no what the inputs are that we are of organ hook up a couple of handlers for any time that the Ruby script puts anything on stand standard out or standard error we want capture that and push it into an array so that we have all over outputs and then we must say that when that child process closes when the research group is done running at that point we want to call the callback function that we get from lambda so that we can tell landed that everything is executed and that would not it so for the purposes of this demo is a very simple hammered out RB already learning is a couple puts 2 output some data and so then if you call this
1 but in Ruby Hello world you'll see that we get back and an object that has the message 1 message it came from our no handler itself and then in the Ruby output which is an array of all the data that the Ruby script put out the command line the like for this is not production but there remains
numerous ways that you can improve on this to make it work but it does work and you know is a proof of concept that you can use Ruby with the service framework In to have
fast is all this stuff I really reasonably
fast but so this is a a chart of the API gateway timing but that baseline down at the very bottom is about 30 to 40 ms mass the entire time that a request coming into the API gateway is inside the lemmas on inside the Amazon infrastructure as from the time it hits the API gateway is routed to land the land executes returns and then the response is returned out of the API gateway but there's some pretty big spikes there they're going up to like 650 or 700 ms so what's going on there that's what the refers to as the Cold start penalties and so basically any time that a request comes on and AWS doesn't already have a land the function lambda spun up and ready to accept a request it's going to go to the cold start process that's basically them provisioning a container loading your code onto the desk in that container and then calling your hand getting its start the so that takes a little bit of extra time and the the cold start scenario can happen either when you just push new code and calling for the 1st time or if you get started get a lot of concurrent requests so like you of 1 the request common cold start happens and its handling of the request and then if another request comes in before that 1 has completed you really get another cold start and then you have to let this run by a by default you can run up to 100 lemmas concurrently and if you need more than that you can apply to AWS to have your cat raised of so I said run
scope to just time these 2 things from outside of the the land environment or the AWS environment and I was consistently getting about this average response time of 70 to 75 ms with the EM Ruby 1 being consistently about 5 or 6 ms more time and so this is you know going over the wire getting into the AWS infrastructure and getting back if we look at
the timing for the land is themselves are they look about like this the warns 1 is the M Ruby and the blue 1 is just a vanilla node-based Hello World now we can see on this that that everyone is consistently about 4 milliseconds slower than the baseline on the node 1 is about half a millisecond of runtime this is only in land itself this is not including API gateway or any network effects this is just the sheer execution time of the the hammer function itself but and 0 and I should mention that in Ruby is is a very scale down small version of Ruby it is not everything so if you need to know everything that really provides for you here have a larger executable that's gonna take longer to load onto the container so your start up cold start time is going to be worse in your execution time is probably be a little bit worse to just because it's gonna take modest too low and in the land timing is you can see cold starts there as well even though this doesn't include the time that your code is being loaded onto the disk it's the 1st time that your code is being run so it's the 1st time is being loaded into memory and so that takes a lecture time just in the land execution itself
i alright so to wrap this up
but it obvious provides building blocks they give you land API gateway all the database services serverless provide some
structure and process on top of everything so that you're not coding and browser or trying to manipulate the API is directly yourself and then you provide them so thanks
thank the this the the the the the you you you you you
Bit
Web-Applikation
Server
Computeranimation
Virtuelle Maschine
Gruppenkeim
Server
Code
Computeranimation
Instantiierung
Rechenschieber
Benutzerbeteiligung
Mobiles Internet
Gateway
Server
Wort <Informatik>
Kartesische Koordinaten
Internet der Dinge
Framework <Informatik>
Computeranimation
Zentrische Streckung
Nichtlinearer Operator
Kartesische Koordinaten
Ultraviolett-Photoelektronenspektroskopie
Softwareentwickler
Computeranimation
Rechenzentrum
Nichtlinearer Operator
Zentrische Streckung
Bit
Datenstruktur
Computeranimation
Autorisierung
Twitter <Softwareplattform>
Spielkonsole
Cloud Computing
E-Mail
Computeranimation
Diagramm
Client
Rechter Winkel
Computeranimation
Lineares Funktional
Gebäude <Mathematik>
Gateway
Server
Einfache Genauigkeit
Kartesische Koordinaten
p-Block
Computeranimation
Punkt
Dokumentenserver
Quellcode
Code
Computeranimation
Deskriptive Statistik
Generator <Informatik>
Server
Dateiformat
Programmierumgebung
Streuungsdiagramm
Instantiierung
Tabelle <Informatik>
Demoszene <Programmierung>
Lineares Funktional
Multiplikation
Dokumentenserver
Kartesische Koordinaten
Mailing-Liste
Routing
Computeranimation
Lineares Funktional
Variable
Punkt
Browser
Festspeicher
Hook <Programmierung>
Mathematisierung
Server
Codierung
Zahlenbereich
Quellcode
Computeranimation
Punkt
Computersicherheit
Gruppenkeim
Systemverwaltung
Profil <Aerodynamik>
Biprodukt
Code
Framework <Informatik>
Computeranimation
Informationsmodellierung
Server
Gateway
Vererbungshierarchie
Projektive Ebene
Datenstruktur
Instantiierung
Bit
Wellenpaket
Prozess <Physik>
Quader
Gebäude <Mathematik>
Bootstrap-Aggregation
Güte der Anpassung
Profil <Aerodynamik>
Kartesische Koordinaten
Whiteboard
Computeranimation
Netzwerktopologie
Informationsmodellierung
Knotenmenge
Rechter Winkel
Datentyp
Projektive Ebene
URL
Softwareentwickler
Verzeichnisdienst
Konfigurationsraum
Programmierumgebung
Textbaustein
Lineares Funktional
Knotenmenge
Punkt
Forcing
Server
Kartesische Koordinaten
Elektronische Publikation
Verzeichnisdienst
Konfigurationsraum
Ereignishorizont
Computeranimation
Softwaretest
Lineares Funktional
Quader
Mereologie
Gateway
Stellenring
Mailing-Liste
URL
Biprodukt
Softwareentwickler
Computeranimation
Randverteilung
Prozess <Physik>
Gewicht <Mathematik>
Wasserdampftafel
Code
Computeranimation
Informationsmodellierung
Variable
Datensatz
Client
Knotenmenge
Netzbetriebssystem
Mustersprache
Lemma <Logik>
Nichtunterscheidbarkeit
Programmbibliothek
Datenstruktur
Softwareentwickler
Default
Graphiktablett
Funktion <Mathematik>
Autorisierung
Parametersystem
Lineares Funktional
Datenhaltung
Stellenring
Wurm <Informatik>
Systemaufruf
Kontextbezogenes System
Ein-Ausgabe
Elektronische Unterschrift
Ereignishorizont
Objekt <Kategorie>
Mereologie
Server
Wort <Informatik>
Verzeichnisdienst
Message-Passing
Zeichenkette
Fehlermeldung
Standardabweichung
PROM
Punkt
Mathematisierung
Raum-Zeit
Computeranimation
Eins
Endogene Variable
Mustersprache
Gateway
Installation <Informatik>
Default
Gerade
Graphiktablett
Softwaretest
Lineares Funktional
Parametersystem
Kategorie <Mathematik>
Template
Systemaufruf
Kontextbezogenes System
Ein-Ausgabe
Elektronische Publikation
Elektronische Unterschrift
Ereignishorizont
Konfiguration <Informatik>
Objekt <Kategorie>
Verknüpfungsglied
Festspeicher
URL
Ordnung <Mathematik>
Zeichenkette
Standardabweichung
Lineares Funktional
Quader
Systemzusammenbruch
Elektronische Publikation
Code
Computeranimation
Arithmetisches Mittel
Rechter Winkel
Beweistheorie
Netzbetriebssystem
Skript <Programm>
Verzeichnisdienst
Lambda-Kalkül
Bildgebendes Verfahren
Fehlermeldung
Instantiierung
Demo <Programm>
Punkt
Prozess <Physik>
Nabel <Mathematik>
Selbst organisierendes System
Gruppenkeim
Versionsverwaltung
Stichprobenfehler
Computeranimation
Hook <Programmierung>
Programmbibliothek
Skript <Programm>
Funktion <Mathematik>
Lineares Funktional
Systemaufruf
Ein-Ausgabe
Biprodukt
Ereignishorizont
Objekt <Kategorie>
Motion Capturing
Verknüpfungsglied
Rechter Winkel
Projektive Ebene
Verzeichnisdienst
Message-Passing
Standardabweichung
Lineares Funktional
Bit
Prozess <Physik>
Datenparallelität
Ruhmasse
Framework <Informatik>
Code
Computeranimation
Beweistheorie
Endogene Variable
Lemma <Logik>
Server
Gateway
Computerunterstützte Übersetzung
Lambda-Kalkül
Default
Soundverarbeitung
Lineares Funktional
Zentrische Streckung
Bit
Datennetz
Versionsverwaltung
Rechenzeit
Code
Computeranimation
Knotenmenge
Mittelwert
Mini-Disc
Festspeicher
Gateway
Response-Zeit
Programmierumgebung
Prozess <Physik>
Browser
Datenhaltung
Gebäude <Mathematik>
Server
Gateway
p-Block
Datenstruktur
Computeranimation
Computeranimation

Metadaten

Formale Metadaten

Titel Going Serverless
Serientitel RailsConf 2016
Teil 22
Anzahl der Teile 89
Autor Green, Jeremy
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/31518
Herausgeber Confreaks, LLC
Erscheinungsjahr 2016
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Serverless is a new framework that allows developers to easily harness AWS Lambda and Api Gateway to build and deploy full fledged API services without needing to deal with any ops level overhead or paying for servers when they're not in use. It's kinda like Heroku on-demand for single functions.

Ähnliche Filme

Loading...