Add to Watchlist

Stop trying to glue your services together; import lymph


Citation of segment
Embed Code
Purchasing a DVD Cite video

Automated Media Analysis

Recognized Entities
Speech transcript
few things good afternoon my name's Max
and today I'm going to talk about why we think that you should stop trying to you your services together important limbs instead who all we need to get that out of the way the 1st where delivery you're aware a online food
ordering service holding as so what online food ordering is all about this basically the concept is simple you and I guess that there's no 1 around here really unfamiliar with it there you get hungry and you go online to 1 of our web pages users search for restaurants that deliver to where you are you compile you water you pay online and then you wait for the food to be delivered so basically it's like e-commerce but with Grant because most but definition and the also the fulfillment part is interesting because food needs to be delivered quickly that something you need to take into account where
operating 34 countries and where headquartered in Berlin this our mask off the year of the Four delivery so just a quick
show of hands who have you attended the talk by Matt about many go before lunch that's a fairly good amount because there are a few things that were not going to talk about but which maps nicely introduced so when they're going to talk about what services really are at war as it were as opposed to monoliths or why you should do go with the service-oriented approach uh way should not do it and how this helps you um knew that we're going to talk about Cloud stuff or doctor or way should call microservices and micro-services or what How
micros Michael but what we're going to talk about is linked to civilians is a framework for
writing Python services and to start with uh I'd like to justify a little why we wrote another framework because use the developers say like a there's something out there already in this case the wasn't as so once we have that out of the way we're going to get our hands dirty and we have a lifetime of fingers crossed that that works or and that's basically the main section of this talk and afterwards were briefly looking under the hood of limbs what are features are there which we don't touch today briefly touched on things like me go and so on TV allowed look and then of the this template units in the end so but I have to be fair and say save if you want to go over things in your own time then there is this and her introduction I you can find an article and important ones links doubling everything is written down there you can go over things in time with you there's even more detailed you will find the exact same examples or our services that we're talking about today beginning try things for cell there's a vagrant box set up that you can use them which will use latent or just you debrief yourself when we talked about today so why do you write another
framework that pretty simple to
there are roughly we've been to in the situation where we said we want services in Python and not worry so let's assume that our decision to go with services was right we were running with the big jungle monolith basically a lot of spaghetti code of the legacy variety is the 1 that no 1
really likes so therefore the idea of going with services became increasingly attractive to us and we wanted to stick with Python is usually use a behavior should do services the idea is that you don't have to worry which language you're going to run with but as we're as we like to do Python every developer should be able to be as productive as they are and if we would not have start with 5 more than I couldn't be here today and and and talk about so that's good and we didn't want to worry we don't want to worry that means he is you want to run the services and an to services there was nothing really that was helping you a lot like that so we want to services and Python and not worry the 1st 2 things are easy to get off the the 3rd 1 wasn't and therefore we cannot link so up with certain
expectations running testing services should be as easy as possible you should not have to worry about that means I as an also or operator of a service you shouldn't have to worry about how to register services how to run and how to configure it you shouldn't have to worry about any of these new code at all configuration should be simple and flexible you should get a lot out of you configuration files without having to write a lot of code to pass them and deal with and possibly should take the same others run it on your local machine the lab environment stage in life but possibly in other countries Even simply by considering configuring it differently scaling naturally should be easy so if you need more resources than you do more instances into clusters yet the client code should be totally unaware of this we wanted to
have the opportunity or the possibility to speaker perceived rather than the HTTP interfaces be able to do to MIT events so that we can do asynchronous communication but we also want to easily integrated or expose HTTP API and last but not least if you want to introduce a new service then there should be a little boilerplate as possible yeah a fair amount of scaffolding helps you do nicely structures so what we came up with
was limit you can find them z Lin file and we think that is where the idea is that you should satisfy all of these requirements so I repeat myself here I think it's
a framework for pattern services and by default limit depends on rabbit and q as an event system and keep for service registry so just 1 more quick show of hands who knows who knows what Robert and q is good some people after enough Suzuki vs. distributed key-value store and that's how we do service request you but you will find about that later
so here comes the scary part
of some people say that I should not animate my slides should not so good on slides um and neither should you ever ever ever do alive laughter because it will horrible horribly wrong so i'm doing I'm going to show
you coach and it's animated and we're going to do laughter so uh there is nothing that could possibly go wrong so to begin with
and to jump to the thick of which we're going to ride services and we're going to exist increasing the introduce new services to see how they interact with the with each other we're going to run them we're going to play around with them to explore the tooling that links brings with itself so when we start with the most sophisticated Hello World example you can think of that's a greeting service and it's funny because not used basically the same example that was not that would not planned that's funny that elements of this greeting service you give it a name and what is supposed to do it's supposed to return greeting for for that name so to begin with we need to file stories this the 1st line
already really 2008 implementation of our service naturally in a P file and we need a configuration file and 1 of sorry that's yeah so to begin with flowers so we start with important and and this is basically where this talk live up to its its its claim that we import length and we want to define a service called greeting and we do so by inheriting from the interface and like I said we want to expose 1 method as interface it's called greed takes a name and we can expose it easily by decorating and with links PC and then what we do inside of this method is we simply print the name which we received saying hi to we're emitting an event to let the world know that were just created someone and lastly where where returning this discrete the configuration file is rather straightforward as well we have to challenge which interfaces to run and where they are located on the Python path because within does is that it imported at runtime to bring up an instance of a service so let's get our hands dirty
and we'll do this within a prepared their box which is readily accessible for everyone add important 1 is building provisions the possible and what you have what is making box does is it has no keeper and reverent you running inside and have to be easy to make things even more accessible they're prepared to sessions which you could easily which then stopped services and panels and which are nicely labeled using the toilet command and this is what we're going to do now so let's go there and run our services and they're under the you don't see the
topmost line of show which is confusing but you should see everything from now on so this is where in the box now
agreed so very friendly with important and there is this team session prepared fired up with not start reading and what you see now
is 2 panels 1 is running an instance of the greeting service on the right-hand side you can see that we're running in the instances in which need to pointed to the
configuration file so in the nose which interface to run on the left hand side we simply have a have a shell and this is where will explore the tuning that means that it comes with so to begin with let's say we we're I don't know anything about limbs also should tell us about the commands that are available this list does so that's the whole lot amount of text word you don't have to read them 1 by 1 will will explore things bit by bit so let's saved we have no clue whether any services running an old or which there are Link Discovery should tell us that we can discover services and indeed it tells us this 1 instance of the greeting servers running as expected let's continue to play dump and say saying we don't know anything about this service I want to get to know something about its interface so linked inspect reading should inform us about the services and and this is more than expected actually use of the topmost function that you see for the top most of our method that's the greedy method the 1 we've just implemented ourselves and below that you see for building methods which you get by inheriting from interface so let's exercise this uh the service we can do
so but ashamed lymph request creating greige whole supply the request body that needs to be valid Jason talking and talking at the same time is hard and all agreed you guys the Europe so what will expect to happen now is the request should head the instance of the reading service supposed to bring something and we should we receive the the readings in response so fingers crossed this works and did on the right hand side you see that it's that saying hi to your Python and we receive the response on our and as expected that's very much on to the next so so the idea is what we
just did so the greeting service
also imaging events every time we're reading from 1 this is something we haven't seen yet and it's emitting events there's no service that consumes them so let's try to service that consumers these events and as creative as well we're going to college listen service and once more we need to follow 1 where we implement the service and 1 where we can figure so we start with the importing and and we define the service by subclassing lymph interface we were calling it listens and like I said every time an event of type greeted because we want to consumers and we want this method to be invoked exactly involved sorry it's called on greeted and receives the event that has been emitted at all it does is that it takes the name from the event bodies and the prints that somebody greeted that name the configuration is just as straightforward as before we have to tell telling that's supposed to run 1 interface listen interface and we have to pointed to where this is located on the pattern path so they can be imported so
let's random in combination to see
how they interact therefore firing the team accession for that and we're going to leap of faith there were not only run in 1 instance of
each service but in this case we're running 2 instances of the reading service in 1 of the reasons for this but let's show ourselves whether you have registered correctly without service registered in discover should tell us so as you can see indeed there are 2 instances of the reading services and 1 of the lessons of so the service is supposed to consume certain events that's certain whether there really is the case so we can event history and that an an event of type greeted with limits the and we have to provide the body also was more needs to be and the name is Europe Python so what we're expecting to see now is once we meet at the listening things is supposed to consume it and and it's to print something in fact and consumed the you can see this done yeah they consume the event that was mentioned before when I when we we were addressing the reading so we would expect to see if print again very nice imprinted as expected so let's request and greeting and see whether they're correctly working together the 2 were expecting to see now 2 when we send this request we expect to be handled by 1 of the greeting instances it should print should return drives and the distances should print was more and thanks to the the 2nd reading instance handled it now if we repeatedly issue this request the request should be randomly distributed over the creating instances and fingers crossed just this worked topmost one-handed and the other 1 American so this seems to work as expected but it wouldn't be
2015 if we were not talking about web services so
that's expose our the functionality that we have within our cell this cluster which is the bleeding-edge reading service and we want to expose it via an HTTP interface what we need to do there will going to write sets and once more we start out by implementing it in Python and configuring afterwards so In this case we import from web service interfaces the web service interface and will also need some that to link to deal with your all mappings and and since we we also want to return that response business as usual we define a web service by inheriting from web service interface we want to expose 1 year which is flash greed supposed to be handled by the Greek method receives the request and we expect the name to be in the 1st place and what we do various when we receive a request we take the name from the query string we print that we're about to greet someone where invoking the
greedy method of 1 of the greeting instances this is our PC basically and then the end where during the the greetings in the response and we also need to configure
it and as a Web service is supposed to listen to a port we have to include this in the In the conflagration that's the only that the distance from the 2 configuration files we've looked at before so let's
run everything together so what we see
here is 1 instance of each server's running with reading and listening and since old habits die hard that make sure that they have all registered correctly and discover should tell us and indeed is 1 instance of each service let's exercise the web service now and see whether they're actually working combination as should so we're listening to port 14 80 and the name should be in the query string that's your Python once more so what we should this request we expect to receive the greeting in the in the response and all services sorry all instances should print something In order to validate that they were actually being spoken to plant tissue this request and in fact all services all instances printed something and we received the greeting in response says by Europe Python over here but there's 1 thing that you might see
already is that the more services you run the more complicated it becomes too well developed with them locally you need more shelves to run the instances and if you want to run several instances of 1 service you need to run them in several shelves that's becoming rather painful and it has become rather painfully already because we want to run free services we need 3 that's a bit of a but there is a link to the
rescue it comes with its own development of a that's the lymph nodes command and what we need to do to get its leverage is within the directory where we want to run our development of them with 2 we use there needs to be a configuration file called but flimflam and in their we configure the services that we want to run and we consider how many instances of each so this is highlighting the important sections so if you want to configure instances you basically telling how to bring up that that instance and how often so we're going to web service instances 3 greeting service instances and for instances of the listen service and within the last section since we have 2 instances of all web servers running their listening to work with you could consider this 1 has a short circuit so let's bring out
our notes you want to see the note on the top right panel but you know that you also see tail within you can subscribe to all the locks all any service so in this case we subscribe to the Web reading and this service and it will print all block statements that receives from the from the instances so let's make sure that
everything registered correctly because there is no output in the lymph node when ship sorry and all discover should tell us that we have indeed 2 3 and 4 instances of the the services running respectively and at the hour of Service cluster as before which the local host that's Screech name goes into the 1st thing want more Europe I and what we expect to happen is once we should this request should be handled by the instances we should see print freeze print statements now been sequence in the note panel and below that plenty of of more about so fingers crossed this works
very nice data so you see 3 print statements up appear almost reads like a little haiku about to read Europe Python saying I do your somebody greeted Europe I from the EU response looks good as well we can see that the reading has been returned as expected and see plenty of almost confusing longer out below here but now consider that possibly your instances might be distributed over any number of machines and if you want to debug something world follow the locks and get information from that it's hard to tell which locks statements belong to each other how can I relate them to the to request possibly very well belong to the same request but the lock statements come from several different machines let's see overcome this problem with the trace so whenever a request enters the cluster and it does not have a trace idea signed yet lymphocyte the trace of the to the request and this phrase it is being handed forward the every RPC requests and the event that is being emitted and then whenever we log is being locked with it so you can see here we have the Web service and return to ahead of all the extra sodium that's where included the the trace and let me allowed to use the I terms search highlighted this room search highlighted function so you you can see the trace is appearing in the locks properly and within your own time maybe you can assure yourself that it actually locks correctly with the tragedy and we can correlate all the lock statements via the trace and that's
very good I managed to successfully go through the demo part and nothing broke so that's just
briefly reason about the communication patterns which we've just observer and the other
thing I went a little bit too far with animated stuff but maybe it's of these entertaining so we started with having 2 3 and 4 instances of the server's running respectively and we issued an HTTP request it was handled by 1 of our web instances the printed something and then we wanted to involved the Greek methods the RPC of 1 of the reading services so what happens behind the scenes is that we can solve our service registry which is cheaper by default and we are asking for all the instances also greeting service and then we pick 1 at random to send the requested and in this case was that was 1 of the request is being sent over the printed something emitted the event eigensystem which is Robert by default return the response and then recognized output on the shelf and 1 of possibly entirely different entirely different timelines 1 of the this instances consumed the event by getting it from the queue and different actually so we see there is there's RPC available which follows the Request-Reply and it's synchronous communication and we also the meeting events that's the pub patterns and that's asynchronous communication and so you see now just inside the already I exactly 1 instance of all of the listen services will consume the the event however their situation we'd like to inform every instance of a service that something occurred and all we need to do is on the lower left you can see that we decorate the service this story the the method which is supposed to consume the events as usual but we say that it's broadcast and what happens instead is that we when we make the event were publishing 2 3 3 to for cues in this case and then it's being consumed 4 times and that as repercussion naturally we would have seen for print statements so is of the the communication patterns which are available with length so what else is commission
with so what's in the box is that what
I mentioned already lands managers you configuration files you can get a lot out of you configuration with very little code it provides a testing framework so that you can you can test your your services following the fashion of if I involved this RBC methods isn't even being emitted as expected them or run some together and exercise the better it's dependencies are basically pluggable so you can exchange zookeeper for something else you could do service registry with something else you could not use the rabbit and Q but something else like cover for instance there service works so when you when your
service starts you want to possibly set the stage for it like you want a provision of database connection and and when to shut it down it's supposed to be cleaned up their service works for this early in velocity do futures so usually classic RPC is blocking and but possibly you're not interested in the in the reply from the service or you or your interested in later so you can do this with the future you can defer the call collects a good amount of metrics when it runs service already and then it exposes them to you but you can also collect custom metrics so for instance if your services talking to third-party API and every now and then this request turns out and you want to keep track of how often this happens this is we can usually do you can also write your own plug-ins for and there even more books that you can plug into and custom code executed whenever something interesting happens that out of the box there is rally in the central planning there it's easy the sorry the CLI interface is easily extendable my colleague of ours approach in topic which is basically like top but for services and you can handle you can receive remote arrows you can get cells and remote services and so on there's a lot more so what's in that hood is that anything that is supposed to be sent over the wire has being serialized with message back
message that is well that's they claim like Jason but a little smaller and a little faster um RPC is being dealt with with 0 and q like I said service registry by default happens with the use of people and events are being the event system is every lymph instance every service instance is a Python process and handled requests and events within green and this is what we do with G and everything that is whether or http and we use that actually for that so since some of
you attended the enemy could talk already as for things that are out there that are similar to what link this there is 1 thing that needs to be mention of course that that's that's not go and he could have a lot of things very very similar almost starting to similar to does things naturally does certain things differently but it's it's for nice and if you haven't attended the talk that you have a look at to also there are other things out there which which don't solve the big picture like them quarreling try to solve it a very very supplies solutions for for many problems like PC or other stuff uh and you would still you have to provide a good amount of new code yourself and this is for me go and in both try to avoid so what we have in mind
for the future of lymph is that we want to have this new ecosystem all libraries for writing special-purpose services using so there's we we have lim storage in mind the monitor which then collects all the metrics some other services and stores them wherever they were just with them what everyone that flow which is basically the idea is to right business processing engines which deal with your business process and manage your entities and whether there is that is to come so do some things up if you can remember there's 1 thing that it is a framework for writing services and 511 I have been successful to date you can find out more and the file and naturally it's open source you contribution is very welcome you can find the the docks and read the box everything's link there and lymph but I O that like I
said this introduction it's all written down in more detail following the same narrative as today at the port management link that we find all the examples that's where the vacant boxes that basically we can go and play around with with uh and last but not least with the fuel of Spanish speaker and you'd like to give this talk again later this week in Spanish then my colleague if you will give the same talking Spanish uh in Spanish it's uh entering this products they have pick out the conclusively feels in Portland flat and what I made a good effort but if you're not doing very good so that work and and he becomes the
same like that because every talk so where wearing if you're interested in working with us in Berlin and you want to work with with you find it interesting um possibly have seen firing you're attending back already feel free to reach out and at delivery euro . com or to see us at our table in the hall with goodies and commuters most important thank you
you and thank you was thank be questioned there are some
or maybe just shot and then I'll repeat the questions so everyone can you or it like this the the but all of this virus your 1st question what theoretically it's possible to talk to the services but you
would you have to do it yourself so you would have to basically we implemented the exactly within any other language and your last question and then get it so your question was whether you can I use lymph nodes the yes it's the the idea behind it node is to be used in development it's not the idea is not to to replace your production how do you should run in production the idea is to help you run stuff locally the the all I guess you can you can spawn anything with lymph node basically just supply command of for instance to run euridice of you could include it there as well and then runs the I'm just going to what
so wise and the support and that the few support I while didn't you use so uh something like the violation the ball model think in place so that since 2 on the questions just both
Python 2 and 3 are supported by donor with which might it starts another we have only had a little trouble with this in the past but it's supposed to be so we're supposed to support but really well and I think you your other question I 0 it should be I don't know about that but to preclude your your question but we have so
about message versioning to support that the that something somebody will have to do on top of your message message versioning
yeah for example if you're on 2 different versions of our service in the cluster you want to see and you run into different versions versions of a service and there is nothing that deals with that out of the box right now you would have to do with yourself I mean it depends on whether the interface backwards compatible but there is you can't it it should would be another so this thing if you want to run 2 different versions right there you would have to run to services or just expand expand into if and thank you for a great presentation and and it
worked out mn it's amazing to see such a polished software on which which promise lot and that's what's on the urine and in Europe backlog what's what's the shoes you're working along what's your roadmap for developing a the 1st so
the videos to further that these of special-purpose libraries I'd like to call them not to let them for the maturity and and then reduce them as open source at some point but right now that it is to simply make them more stable everywhere were going to run it production anyway so this is something that will naturally and I will naturally grow and mature with in the future hi an item
leaf right but uh and this stuff that using an sealant Q for the opposite handing the obstacles and property and Q 400 the events is how considered perhaps uh he's using not into football and then that redefined extracted fantasy ought to do experiment it was called for
instance Mamiko uses 0 users are perceived goes here 0 cute sorry the and you there as well as far as it was a design decision not to do do democracy over over something position as reference to actually my question
was going there there were around if it's also possible to replace Robert and Q with 0 and Q you the prob Bob saw reactive and so
it is but you said this pluggable but is already implemented or is it something else so I was expecting your question therefore preferred something um so this is this is the part of the don't live where my which I actually didn't want to show because
it's a little confusing however what you can see here is um this is actually where things are pluggable so you could provide another class which just registry or events this is what it looks like a by default but you could provide your own back and I see everyone's eyes narrow so yes it is confused and just 1 more quick question but I've
seen in the animal the water that these may be in the simple examples just names of flow of services and the classpath so wouldn't it would it be possible already just to have a decorator that defines the name and then just launch with like getting rid of the animal file and just launched the instance just providing the path to the class uh well in theory yes that's possible but this was the idea
behind this is that you could group several interfaces together and run them as 1 service um and what I think this is just more flexible is then you don't start to mix what's a new configuration what's not this way you have everything in a configuration and that's where it is I think
it is most of things that
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation


Formal Metadata

Title Stop trying to glue your services together; import lymph
Title of Series EuroPython 2015
Part Number 73
Number of Parts 173
Author Brauer, Max
License CC Attribution - NonCommercial - 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.
DOI 10.5446/20162
Publisher EuroPython
Release Date 2015
Language English
Production Place Bilbao, Euskadi, Spain

Content Metadata

Subject Area Information technology
Abstract Max Brauer - Stop trying to glue your services together; import lymph What if you could focus on functionality rather than the glue code between services? Lymph is an opinionated framework for writing services in Python. It features pluggable service discovery, request-reply messaging and pluggable pub-sub messaging. As our development teams are growing, we're moving away from our monolithic architecture. We want to write services and not worry about the infrastructure's needs. We want development to be fast, quick and simply work.
Keywords EuroPython Conference
EP 2015
EuroPython 2015

Related Material


AV-Portal 3.5.0 (cb7a58240982536f976b3fae0db2d7d34ae7e46b)


  853 ms - page object