Introducing Microsoft Orleans, Milica Panzova

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
until you dear here and there everywhere thank you for joining us tonight my name is Melissa I come from Cebu scorpion and tonight I'll be talking actually will be discussing about Microsoft audience this is my first time here in Minsk and you have such a city it's so big and clean so eventful so I hope I will have the same experience with my presentation here tonight before we start I just want to check if there is someone who maybe work with the Orleans at the moment or maybe had some chance to do some reading about this framework okay so great that you're at the right place this will be actually an introduction to Microsoft for aliens so what are we going to see tonight is this is actually the agenda first we are going to do and see who and why create at Orleans what was the motivation that provokes I want to think about a framework such as Orleans and where it is used today secondly we will see the basic concept of Orleans then we will see how to install and how to use it a next step will be how to expose the logic heart rate Web API what are the benefits and how easy its deployment and how are distributed in few steps system can be achieved by this framework and at the end summary of all we are going to see so let's start first of all Orleans is something that is created by Microsoft back then in 2011 and what were they thinking of when they were creating this framework is actually how to build a framework that will be easy even for non expert developers to use it and at the end to get distributed system which is easy scalable how to get efficient code and how to be easy deployable so in one words to be efficiently an easy created distributed engine so that first of all it was used internally in Microsoft and the first product that used this framework was hello for game and it appears to be very useful and then start using this framework in other industries so up to now Microsoft has a number of 343 different industries where this framework is used so here comes the banking industry Visa has some product that is based on Microsoft audience also in the manufacturing industry and much more in 2015 this framework becomes open-source and since then it become point of interest for us so for us as a developer it's always a challenge to build a distributed system which will at the same time cover all these four topics like high throughput response in almost real-time high availability and to be by default cloud scalable so audience has covered all these four topics one by one and we will see in the presentation how is this achieved and at the end we will come back again at the same points and see how was difficult or easy to come to these points what is actually Orleans let's repeat one more time so that is a framework this framework is used for building distributed system and as a distributed system we understood oops sorry wrong button you can see the presentation several slides up front and we can start again so let's be careful and use the real button okay so we will use Orleans for building software with two rounds across number of machines in such a way that the machine cooperate and act as one large computer so that's the idea of distributed solution it is a very simple programming model and it solves problems that we usually have during our development the development where we have competition for one same resource and in such a competition there is a thread locking and this model this framework solves this concurrency synchronization problem in such a way that it used different grains grain is one of the basic concept for volumes that is a c-sharp class we will see later which actually runs in single threaded mode and all methods within this class actually are implemented as synchronously so as a tasks we will see in a real example in a demo about this so wow what is important to be remembered from this is that it actually solves the problem with concurrency in synchronization so the primary focus of Oriels is actually not just to build a distributed computing system but also to allow non experts to write efficient scalable and reliable distributed services so if a developer is familiar with object-oriented programming then it will not to be any problem to start and writing such systems by using Orleans in a base this is a actor framework but what is the key innovation here it's a virtual for those who are familiar with this model of actor framework so it is a model that works with actors in one big container which can be activated on different servers but there is it's pretty complex for implementation since we need to take care of lifetime of every actor which is actually can be mapped with some class like like a model like maybe a user on Sur or some different entity so we need to care of lifetime of these actors in a way that we need to activate them then to deactivate to dispose and Orleans is something that is doing this for us so we do not need to care about the lifetime of each actor but Orleans is providing all these activities in behind for us so how is he achieving this by using this actor model which is a mathematical model since 1970s and it's a model that it's treating concurrency activities for a wondrous resource for example what are these covers if I have a grain which we will see what is actually a grain that is used by several ApS in a frequent way it will be kept in life for some period of time when these activities are stopped then it is so smart then it can be deactivated by itself but it is more than usually used by other frameworks then it can be duplicated on different silos and be live there and it can achieve a real-time responses when we need to achieve a high throughput and quick responses so as I mentioned here we have a virtual actors which means this is a Orleans a phrase with all actors that are living all the time and active and we do not need to care if if it is or it is not active so this is just a visualization of what I explained so I will repeat it one more time to be more clear these are actually doctor this is entire model actually at retile Trier model and this is the actor as a middle tire all these entities are actors and they can be activated in different machines so instead of going and writing a lot of code for each of the actors how to be activated when and when to be activated here is Orleans where this all of this job is actually implemented by their side each side so if we have a client this client can be a VAP API or some console application and if he is searching for some entity and searching by some key so then a to return the reference from that entity from that actor for us and then we are invoking some methods and this is the place when audience is taking his activity so he is looking for the doctor if the actor exists and all and everything is ok if he does not exist and it is activating the actor and after actor or a grain is activated it lives in a memory for some time so with that it leaves some important information in memory so each time a new request is made then the response will be very quick it's an illustration let's imagine that we have for some devices which need to communicate to some server and send some information from their device like a temperature and if some maximum maximum temperature is reached then some additional activity need to be taken and let's say depending on the temperature level it's a matter of that or no so the responses must be very quick and we have some knob we have some number of hundred thousand devices and when start sending when they start sending the information to the server how the number increases then the responses become very slow and we start we are starting to think about scaling but we can scale at some maximum level in order because at some point of time we will achieve we will come to an ask well bottleneck we're not all requests can be handled and we start to think how to solve this problem with with quick responses and high throughput there are several ways one of the way is splitting the model in a different pieces but we will now focus how to solve this issue with Orleans so we're actually starting with the basic concept of Orleans this was something like introduction to the possible cases where it can be used one of the basic concept of Orleans is grain and the second one is silo so those are the two terms that define Orleans as a framework what is a grain grain is a simple dotnet it makes differences between other class just by using marker interface and this marker interface is used so that only us in runtime take additional activities for this class so if you create a class and just put a marker interface dot not automatically knows what to do with it do to do or leaves framework then the thing is that communication between grains is because we may may have a different grace and they do not see each other even though in their in one same cillo do not share their states but they communicate each other using the a synchronous message passing technique and they cannot access their shared state so if we have one same grain activated in one same silo so for two times in order to achieve high throughput and real responses or even if we have more silos they cannot see and even though if it's a same grain but with different key they cannot see each other a shared state so there need to be implemented additional code for synchronizing if needed a state so this is actually a stateless model the second concept is the silo silo is something that holds and hosts all grains and silo is taking care of a lifetime of each grain so it is just a simple dotnet dll that can be used as a service or can be used from a comment line we will see both examples later on and silos are designed to work together so we have different more silos they can be raised on different machines and we are achieving actually a distributed system with this way the silos host grains and they the greys communicate with each other from different silos this the representation on illustration so we have several devices though devices web api contact different silos since orleans does not have public api and can cannot expose the logic from the grains unless we use for example of a pay P I so we have some requests here the pay P I send the request as second step to the sellers and we must give one primary living silo and then we might have a second there is secondary silos so the request comes here and the grain finish the work and then the response is sent back if you see here we the grace does not have binder in communication whether it is within the same silo or a different silo they distinct each other by one key which can be a string core which can be a good depending in our interface implementation for the grain so let's go one by one Olien surrounds a silo in each machine so this can be a different machine and on each machine we can raise a different tile within the silo a grain is activated so within silo one grain can be activated the grain may talk to other grains so they can talk within the same sale or different silos then when a request is complete so here if a request is complete the grain is not deactivated but it's kept in memory so every next request to the grain is handled with a very quick response this is the same illustration that we had just a one more time I'm bringing up to you because now we are going to see a code about it so and this is the place where we put all the as middle tire and now let's see the demo but what is important I can share some interesting tools here there they are as a template if you decide to use okay just to make here if you decide to use ordnance as a framework you can simply go and download from marketplace this tool and I'll buy you will get in Visual Studio doh Street templates available and you will avoid some manual coding for now it is supported for 2013 15 and 17 2019 is still not officially released still a release candidate so they cannot be used in 2019 but the project created in any of these versions is compatible in 2019 as well then I will show you now the these are the interfaces always talking about so we have a grain interface collection which holds the interfaces this is the implementation of the code the classes with its implementation and this third part this is this is a process which is used for testing the grains it is activated and it simulate at the same time a silo and a client so it it is at the same time the silo we saw that horse grace but also simulate a client and it's only for testing purposes to see how grains works the first demo will be using this type of test host application so what are we going to do in this first there actually the first the idea of this demo is to see how easy is to start Orleans framework and use in a simple application with those three templates we will see the moment how we will activate grains since when when we start the application and we have a client and when a client requests something of the paper I from some grain the grain at the first moment it's not activated but we don't care about it so only else in the run time when the first request to the grain is received will activate the grain in the silo and we'll cap it kept it there for some time and provide us all responses that we are searching for so we will see with the message if there is no existing activation a message send it to trigger actually the activation of the grain and that the lifecycle is managed by Orleans runtime so at some point when we stop asking some information from the grain it will be automatically deactivated I will now switch to here so this is the first project I have created a project with the Orleans template so these are the interfaces here the grains and this is the daftest host actually I named it silo host this will be simulating the client and the server at the same time it just one grain just to be just for demonstration purposes so I have this grain like hi interface like I called dog's grain and I have one method here implemented what I do with this green I mark it with this marker interface and I say this can be like I grain interface or can be like I grain with good he or I I grain with integer compound key or whatever they're both they are all doing the same job which is marking the interface so that only LC runtimes know what to do with it and now we have a method which is defined as a task which means all methods within the grain must be a syphilis in its implementation this method this is the implementation of this method it's very simple from a console we will send some values for the temperature and then if the way is higher than hundred and then some last temperature stored which will be persisted within our grain we will check that and if there is some value higher than hundred and higher than last temperature measured then we will display some message this here within the grain is actually overriding of this method and where this method comes from if you see here in the implementation of this class except that inherits from interface we have something like a grain and this is a base class if we just for a short quick look in this base class we will see these methods so we can use these events and put some custom code that we need which we do here in our implementation so with I took the on activate a sync event and what I wanted to show you with this example that when the first time a call is initiated to this get temperature method we will see the moment of activation in green and every second third and a call this will not happen since the grain will be leaf and here in the dev test house I load this is the code that will be implemented so this is a simulation of a silo we use some default configuration we are not configuring pores or whatever so it will be used all the defaults just to be started and then we have also apply using the default configuration and this client will be a console application and then we will start inserting values and see what will happen now I will go and show you so this is the application first Asylum is initiated and then a client the process is still not finished since when finished we will have these messages as you see in the code we put here a message saying that a silo is started and afterwards that the client is connected as soon as we see these messages we know that everything is in on right place so here you see a silo is started and then we have a client connected you see here a lot of IP addresses and this is these actually are default ports and this is the localhost where the silo is activated this is the address of the port where the connection between the client and the silo will happen what is expected from us is to start inserting some values so this is enough my first video and first all to the grain and at this moment that's all right now enter this is the moment when the grain is activated so it says activated grain first grain the name is first grain because that is the key I inserted for the grain I can activate 2 or 3 or 10 more grains within the same silo but with different ID and they will have a local state of the of this property last temperature which will be different in all grains even though it's the same they cannot access the shared state so next I would do is enter some new value let's say 220 and then I will not see again this activated grain message since it is already kept in memory I can continue doing like this but they idea to seize that I can make communication from a console to a grain which is activated in a silo it just several lines of code so I will stop this and I will continue further and with some next demos next would be we will remove now this default def test host silo and we will use of a ppi as a client and we will use the orléans host DLL to activate a silo that will be actually the second example so since the audience did not have a public API we cannot use them unless we create VP Web API and connect within the Web API so this a short example for the demo I will return back again on the code so we will run a local silo and connect it to the silo from a spinetto web application and then with this by moment of introducing API or ICP dotnet web application we can here use if we like also the authentication and authorization step when we are going to use let's say Web API or application but I will skip this so we are not interested of seeing how authorization or authentication will happen but we are focusing on communication between the VAP API and the silo so this is what is happening in code now I will open my second presentation we are keeping the interface we are keeping the implementation of grains nothing will change this here is now console application from which we are going to start the silo and we have a custom configuration which is always configuration in here instead of using default settings that we saw previously I say I want to use this address to host the silo and communication between the client and the silo will happen on this port this here is for interest in terror silo communication actually when the grain need to talk to each other this is the port for setting here so just a simple configuration we have a global here this seed node is actually the node for the salad that is considered as primary and since we have only silo one seller it will be automatically a primary and these are the defaults so now I have a console from which I will start my silo and here I have a VAP API and this VAP Web API I have here in initializing columns so an application start I have a code which says initially Solon's and all you have to do for instance initialization is just to provide a client configuration XML file and this file will contain information for the silo the address of the silo where it will be located and port where we need to communicate but we need to also make reference of Orleans here in order these to be this magic to happen so let's see the client configuration so nothing except this here which says the silo is hosted on this address and you can communicate on the silo with this port and here in the videos controller I have over right get method so I have something like this I make activate and make instance of the grain we have created previously with ID temperature grain and then I make iteration of five times and I get some random temperature so this random temperature is actually I new method below this get temperature method which says take the last temperature from memory and then increase it for ten what is important here is when I start Web API since here on application start I'm initializing Orleans and I say start a communication be prepared for communication with the silo that is configured on this address I first must activate the silo otherwise this will not happen and the AP cannot be started so first of all I am going to activate the silo and then I will start the API so okay okay here it is if you notice now okay still not activated in the previous case we were using default settings and the communication was happening on port - - - - now we use this number of five ones and see with this way we are ensuring that the Orleans configuration file is read second step would be to activate the API and waiting for the information as soon as we have this information we are actually proving that Web API in a very simple way can communicate with a silo and there are two different processes so this is the since I'm a reading venues from my local temperature property and it's a increased by ten and since the grain is activated and kept in a memory that means that we are using a value which is in memory so next time I call I'm not restarting the that property of the grain from the beginning but I will increase for every new coal so I'm refreshing refreshing and this value is increasing so we saw that this is very simple I will now go to the third demo not to switch from duplicate to extend that monitors I will give you a short info what I will that be so the idea is to see the deployment of the audience and how we are going to cover the easy scalable process since now we saw that we have a silo which is on one machine and that is actually not a distributed system we need to have several silos activated and to communicate each other the last example is actually how to make the distributed model active so I have a third example here it's the same here I have the same interface same grain this is the silo this is the Orleans configuration but with one difference here and that is that I say I want to use with two silos this is the default so if I start with the default I will have only one silo activated but at any time whenever I like I can include the second silo and that second silo will work on these ports and this is defining what will be the primary cell why is the primary cell is so important because its delegates the request oh the I have here VAP API that will communicate with that primary cell and also I will have console application which will help make a huge number of requests and they are all directed to the primary silo primary silo if at one point of time detects that the grains that are hosted inside it are very heavy loaded it automatically activates the second silo and start transferring requests there so I will have two silos managing my request with very with good response and in where in short time and I imagine that those silos will be hosts at a different machine so the load will be actually put in two different machines now let's see the example here when it comes to the Web API I don't have nothing change so my I say point to the primary silo it's the same here point to the primary silo and you will see how automatically heavy loads will be redirected did what is this console doing in short this console is just randomly here if you see when I will run the console I need to put a key of a grain since that grain that that will be activated from this application will be with a different key let's see what will happen first let's activate the two Silas but now instead of using the defaults I will use the dotnet DLL that is actually embedded which is Orion host and I will show you how to invoke cell activation from a command line so this will be activation of the first cell it runs on this port so the second cell should run with the two at the end if you note is the configuration you see this is a different part now I will start my web api and at the same time while waiting here around this application what happened here is we have ready second silo because probably you saw here message the de silo is activated here it is a silo primary startx successfully here on the second silo you you will see here the primary in the second tower to make a distinction between and the second side was started successfully now I have this is the Web API I will make communication from my client this is what is listed and here let's see the Silas sorry I will invoke it here one more time since I'm not sure okay we have five more minutes left to complete everything oops I will do it like this the name was okay the name of the green I will activate is whatever so I should not receive while this is happening probably this needs built because there is some issue with my application here I will well the okay build succeed so it was fast I will just show you the ending of this presentation and just the proof of what are we going to see at the end which will take very short so this was the oops this was the fifth chapter about deployment this is what we already seen that audience is designed to work as a distributed systems that should run in several as a cluster so need to run across a number of machine we must choose a primary silo to see direction a redirection of request this is the last demo that was not successful but it will work after these slides I believe then when new silo join the cluster then we can easily redirect and put it in a game and addict agreeing calls there and everything already said about the configuration that we have a client configuration file which is 6 ml file that we need to configure on a client side and this is something that need to be configured on a service that will run as a silo and these are the explanation for each of the nodes so this is for integer cell communication this is for client connection and this is how to define a primary node which we already seen this is the demo I'm trying to work out and at the end with this demo I just want to confirm that first we started about grains what is grain that is a simple dotnet class then we saw how holes that are the grains in this dev test silo now we are hosting grains in two more silos and at the end we learn how the clustering kandorians what the clustering is actually this last demo and with the last example what we actually should proof is that we will have when we have a high throughput of information it can be easily managed and we can we can have for real-time responses which are higher available and by default all the else is cloud scalable higher availability means and we will also see that that I can have 10 silos if for some reason there is some electricity issue let's say the third silo is out of order when I make a request to that silo it can the grace that were activated there will be automatically reactivated in another silo but one thing is that if we don't keep state of the grain somewhere in storage the state will be lost so we honor the process of reactivation we can just read what is the last state of the grain that was deactivated since we activation methods and events and again make a high available process so that is actually the last thing and I will come back one more time just to see here and prove everything that we said by now I have rebuild the process and I will now activate again my silos when we are ending the presentation with this demo oops one more time primary silo activated step-by-step let's see what will happen now I hope it will work at least it was working when I was testing this is the secondary cell this is the Web API let's see if something will happen no it's a persisted so it will it already yes of course that's the problem now it works my silo from the previous project was still not deactivated so I devote deactivated and then start running here so I have here way using my primary cell here never mind I'll activate it several times and this is only the primary sellout if now I will again oh good so I'm invoking several times and if you see all the requests are still handled by a primary silo a grandidis activated there now I will try to make some heavy load using this client application so the green can be called whatever I'm expecting for some values here it is and if you see now the Pratt the secondary cell is not activated here let's do some work okay and this will be the last fine okay and now before I do this I will make something like okay work and work and work and work oops come on and finally the secondary silo is activated and here it is the secondary start working my requests now what am I going to do now is I will kill my secondary silo and make the same attempt to the secondary cell so bye-bye I don't have electricity bring me some results this one is here also this one is here and now he's saying that the secondary silo is not active in this case it will fall because I don't have a try-catch mechanism but if I revoke the same process again it they will be automatically handled and reactivated on the primary cell so this is just to see that it will see that it is not active and then when I try on my second attempt it will serve all my requests so see here it says response did not arrive please ask your boss primary silo and give me my results and he says ok so that's all thank you for your patience sorry for having maybe 10 minutes more than planned but it was important for me to see at least the point of these Microsoft audience presentation thank you one more time I believe we can discuss more if you have any question on land talks just to live Yuri to proceed with his presentation think about the idea of the program
Info
Channel: SPACE
Views: 2,079
Rating: 4.6923075 out of 5
Keywords:
Id: _zHPaAanpus
Channel Id: undefined
Length: 51min 28sec (3088 seconds)
Published: Thu Mar 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.