ASP.NET Community Standup - Scaling ASP.NET Core apps with Orleans

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] do [Music] do [Music] [Music] [Applause] [Music] hello welcome to the dot-net community standard uh so i'm john galloway i'm a pm on the development community team and today we have with us brady gaster welcome brady come on it is that magical in between time i heard someone on twitter call it the limbo it's after thanksgiving it's before like it's before the december thing it's just basically everyone's gone until january it's it's that wonderful time where you can go through and do the things you actually wanted to do during the year so yeah it's like all all the things on your to-do list that were marked as like backlog or creative time or whatever hack time those things are actually getting done now it's kind of fun so today we're going to be talking about orleans and is that does that kind of fall into that a little bit for you is that something where you've wanted some more kind of focus time or have you been working with orleans a lot this year well this year uh reuben and benjamin and the folks who work on orleans i guess it's really good benjamin i know me um they kind of came over to uh the team uh they teamed team.net team uh and we sort of i don't want to say adopted orleans like we we we'd always been a big fan of it uh good friends there hey kevin um um we've always been a big fan of it but it never been like you know in the in the in the equation if you will yeah um and once we brought it in we started doing i started talking to customers both customers who were just getting started with orleans so if you're one of those and you want to like talk to me and tell me what your experience is like or you want to sit with me for an hour or two hours and just do some hacking totally into that um believe me i've been doing a lot of it myself and then we have these new services like the azure container apps service which is going to be great for orleans and we really want to start investigating opportunities there so over the past months i've been talking to customers like i said the new customers are just getting started with it just getting started with the docs the team has written um and also talking to big customers like a lot of big customers that actually use orleans i don't know you know how anybody right now uh but let's say that let's say you're a big game uh or orleans is a really great use case for very very large scale games with lots of players and lots of objects in the games because those objects can be represented uh with what you'll hear about later is essentially a orleans virtual actor is called a grain so we'll talk about grains later um but you've probably had a reuben on the show and i was looking forward to kind of doing one myself because reuben might pop in as well uh ribbon goes really deep and talks about the topology of orleans and the virtual actor model and ruben's a heck a lot smarter than me and i just kind of stumbled into orleans this year and started talking to these customers that are doing amazing things with it um just you're talking like two to three million objects in memory at all times uh running across nine regions you know you know hundreds of thousands of machines you know pumping objects around it becomes very powerful and um it's been fun to like think about it from the perspective of a web developer and think you know how would i use this and try to come up with ways to to show it off so that's been kind of fun you know honestly i think that's perfect because i think a lot of orleans presentations i've seen they go deep really fast and they talk about orleans specifically and i'm really interested that's actually i titled the show like scaling asp net core apps with orleans because the demo you showed me seems interesting and i'd love to just kind of get like hey i'm an asp.net dev what's this orleans thing you know right exactly cool cool uh before we dive in as always we're gonna go through the community links so we've got some cool community links going on i'm gonna send them out in the chat so you can go through them at your leisure and let's switch over to my screen there we go so here's our list of links and not a whole bunch right now it's kind of quiet um but you know some some good stuff let me see uh so first of all nice roll-up pose from jeremy lichtness about uh ef core6 tons of stuff in this release um so uh what's cool i love the format of this post it's kind of a like here's your here's what you need to know you know so stocks and videos and deep dive stuff so uh you know cosmos db is a big thing uh support for compiled models so you know uh and specifically calling out things like uh distributed apps and uh azure functions and just getting that fast startup time by pre-compiling your models uh configuring conventions so this is uh setting up conventions that you would reuse across your entire application uh migration bundles this seems really really cool honestly this one slid by me i hadn't even seen much about this um you know there is a workflow where you can um i may be getting close and away from my mic so i'll try and stay a constant distance from it you sound good okay uh there you know there is a workflow with migrations where you can you know as you're developing you're just make some changes add migrations and you know update database blah blah blah blah blah but it gets a little trickier when you're actually you know like in production you actually have something that's actually running and you want to more closely um manage how those migrations execute and there are some open source systems out there there's some different you know migration systems that people use um this is nice to see ef like you know directly kind of addressing that more and then performance and temporal tables this is something that temporal tables have been since uh i think sql server 2016 um so adding that support and graphql and then here's all the packages what's that that's my favorite part of this blog post jeremy's doing some amazingly exciting stuff for the graphql community and uh i would just continue to watch what he's doing there um you know you know like john said i would use i use a little bit of my december every year to do one of jeremy's projects from the previous year oh it's a great day great projects every every end of year uh and i like like last year it was like the uh like a choose your own adventure story uh he did with durable functions i was like i have to play with this so this this is what i would encourage everybody to look at this year some some graphql stuff it's really really fun stuff i really like this model and when i talked to jeremy at one point i um i said like hey and and i'm sure you know jeremy's got tons of great information coming in and stuff but i really liked what you showed me about how uh the swa the swagger integration the open api integration with asp.net core kind of works smoothly with and swag and swatch buckle i'm like just check out what they're doing talk to i think i may have even sent him to talk to you but like the the whole way that they're doing graphql in partnership with existing great open source projects i i just love that kind of model right good stuff all right moving on um andrew lock superstar blogging superstar going through his uh six or his 12 part uh thing on exploring.net six and here he's looking at a really kind of useful thing which is how do you reconcile how do you update a net 5 application to net 6 because we've changed around the program cs and startup cs and how do we kind of integrate that together and you know where what is all my code where does my code and my startup go etc so great options that he calls out here one is do nothing like you don't need to change around your program and startup it's it's all kind of built on the same kind of hosting uh intrinsics underneath and you can just update your app to runon.net six so that that is the thing option two reuse your startup class and so here it kind of looks at here's the general structure of a of startup cs and then so you can actually just in your builder you can use use it to call into your startup class so and then uh option three here is you know kind of like if you're starting with a new application this is this is kind of a way of structuring your app is to create those local methods and kind of put that startup stuff into your program cs and i think we're definitely going to see i don't know if you've looked at this much brady but the whole kind of like the grow up story for the kind of simplified pattern you know it's like i i love that it's simpler i love that it's not a huge bunch of files and confusing stuff but i also don't want it to be like a 2000 line long program cs right right so i um i have done quite a bit of that you'll you'll see some of the code that i'll show today i'm i'm going to go a little nuts with it in fact glenn's always taught me right middleware right middleware uh so i actually really like it this kind of makes me think differently about it uh in a meeting with reuben the other day he you'll see in one of the samples that i'm actually passing i've got an extension method and i'm passing the eye configuration to it and of course ruben and i are like how can we mitigate having to pass eye configuration you know and it's like now you want to rewire everything it starts to compress so yeah i i think we'll probably come out with some you know there's going to be some patterns that emerge from the community i think there's going to be some guidance we're definitely kind of i've talked to several people that are kind of thinking about how to like you want a smooth like we've got a a good model for very simple apps we've got a good model for very complex apps and then how do you move smoothly between them so i'm kind of curious if like folks who've always picked my boss uh folks who've always you know you know done done the right thing by by going and like written that middleware and written those extension methods to wire everything up and like do all your stuff you know properly if you will um rather than just services services services and like wire everything up i'm kind of curious if folks who've done it that way if they're having less pain moving to this top level approach or if it's like harder um just just kind of wondering if you know people are like adjusting to it more easily i found that i had a lot easier time adjusting to it having adopted a write your own middleware approach to things so yeah yeah that's a that's a good point okay there's one other good option that andrew points out and i love this which is consider extracting modules and using carter so we had we had jonathan on the show talking about carter and what's really cool here is it's got a whole kind of discovery system for a module so you can basically create different modules and then you can extract things very easily out to that so he's got a link over to the community stand up that's something actually that you know i want to continue doing as we move into the new year is have more regular like get some open source projects on here we're trying to kind of get a good balance of which shows like on.net traditionally has been the like full open source project deep dive and we have some others like that but i think i think this was a really good case where it's like you know it's a really good um it's a really good option to be aware of cool all right a few um few just uh templates and things that people are have shared with me so one is uh damian bowden and this is a template that that does blazer bff back end for front end azure id so the idea here is um you're creating a back end for front end from a blazer web assembly application and then as you said this uh this removes the tokens from the browser and uses cookies with http requests so this is this is something where like every time i work with azure id i have a decent amount of relearning to do or reading through like and you're trying to find the template or the tutorial whatever that matches your thing and then it's like oh okay but they're doing it using this kind of off and i'm doing this or whatever so it can be tricky to get that fit so this is a really nice one to be aware of for people that aren't aware of this kind of back end for front-end pattern i actually like uh i like this post there's there's several out there but this one's kind of like what is bff and um so it is best friends forever but also it's this whole and i'm not going to go through this whole post but it's basically describing the problems you run into when you're creating uh applications with a lot of clients and they're authenticating to back ends and you've got this kind of complex uh deal with all this i'm scrolling down because i want to find this kind of this this is what we're talking about so we've got our clients we've got our back ends for the front ends and then they're communicating with the api services so anyway so i'm including that in there i i like that it's almost like uh it's almost like micro service thinking applied to writing your front end and you're back in together yep exactly exactly uh okay uh just uh shout out to the full stack hero team uh this is the.net six a web api boilerplate and uh this is a another kind of template this is a pretty um so this is cool this is net six support in 005 rc and a lot of new features in there and what's cool to see too is a lot of community you know community chipping in here uh so there's a whole kind of quick start guide what's nice with this there's a thing in here where it talks about what all it does so when you're creating a project you can do file new project and you can start pulling in all the different packages and you can read all the things of how to wire it all up sometimes it's nice to get something where somebody has kind of built a you know put all the parts together for you and you can at least see how you like it and which ones work for you so this has things like um you know opinionated architecture as dapper serialog has api versioning auditing you know different things like that and support for hang fire different stuff so cool congrats to the team on that all right just a few left uh christian heilman tweeted about this new feature this is uh in the latest release of edge you can do open from browser tools you can open individual studio code so i very frequently will be in the browser tools i'll be going through and tweaking things and then i'll be copying my css back over into you know my actual source code what's neat with this is you can actually create a workspace and open directly you you can synchronize that workspace between vs code and your browser tools so they've been doing a lot of work with kind of synchronization and working with uh vs code and browser tools together so some really neat stuff there so anyhow and last one here just a plug we're doing this uh learn live modern web development with net six series and so we uh we it's we've got a team uh you know the team that i work with it's been doing these regular shows i just did one yesterday creating a web api uh james montemagno and i walked through this but these are hour and a half shows and you know just live q a and lots of um you know coding mistakes and we'll just do it on the fly and figure it out but we're we're going through these learned modules so it's a great place to learn new stuff and i am done all right brady so orleans what the heck are we talking about sweet well i uh did what any good pm would do and i came with a deck all right sorry uh if you can pop that up there there we go so i'm gonna borrow some slides from a recent presentation that we did internally no secrets i promise uh with our fantastic friend maria in which we were talking uh to some folks uh in our leadership about the progress we've been making on minimal api as well as on orleans um and i'll vacillate between uh my southern pronunciation orleans and the proper pronunciation early ons i'll just go back and forth so just just keep everybody on the test um so uh we got to we got to talking about it and when we started to chat with customers especially customers who you know like john and i you know we know what a controller is you know what a view is we're doing stuff forever um it was one of those things where you know they kind of wanted to understand how it fits into their puzzle pieces and as we started to talk to the customers more and more we started to see that this was kind of the best way to think about if you're thinking about you know orleans from the perspective from of an asp.net developer this really kind of stuck with a lot of the the folks that we spoke with and we talked to people who were you know architects we talked to people who were devs uh a bunch of different pms that we spoke with as well as some of the folks who were like i mentioned earlier already have pretty high compute apps deployed uh either on or off of azure uh using orleans um and really what we found was that when folks kind of adopted this mentality uh if you think about a grain as you know almost like the stateful request response it's that thing that lives in you know some back end server somewhere what we call a silo you put a grain in the silo get it um if you're a farmer you get it um um and essentially like you would run a controller on the server you know the silo becomes the server for you know those grants if you think about the stuff that you know fowler and the team have done with you know bedrock and the asp.net underpinning and kestrel it really hosts all of those things it can host controllers can host views it can host my favorite things signal our hubs um and then my new favorite thing uh you know or orleans grants so what does it look like to host an orleans let me go ahead and go to the next slide here we can go back and forth on this so you'll see that we've got the front end on the left side and then we've got kind of our storage which you know i typically use azure storage when i'm doing stuff with orleans and in the middle you've got what we call the orleans cluster and that could be a kubernetes cluster or it could be you know a series of other compute a lot of people run or leans on virtual machines as you'll see me doing a little while you can actually run orleans on top of azure web apps are on top of azure container apps the last one i don't have quite running yet because i was a little took a bit of a daunting example i'll back it off and do something simpler in the future but essentially you've got a model uh essentially a actor a virtual actor or a grain for all these different pieces of functionality so you might have a grain for a player you might have a grain for a monster you might have a grain for a rock you know what i'm saying um and what those end up looking like is all of these things live inside the cluster you might have one for each individual user as i've got a sample of here or one for each individual language as you'll see in a sample that we do in just a few minutes the machine part really doesn't matter because as you'll see in a little while those grains can live on any of these individual silos or these servers that live inside of that cluster and if i'm using something like azure container apps where i want to you know dynamically scale based on need i might run four machines or i might go up to 40 machines if i actually need that many just depending on how much compute i might need so there's that i have a question from jose silva orleans integrate well with dapper or do both have similar functionality that's a great question uh we are actively the orleans folks and the dapper folks have already had like a series of meetings um we like to think of orleans as a thing that's been around and started kind of in the alt.net community and you know grew up a lot actually started in microsoft research and driven has a ton of talks about the history of it and different ways that it's been used it started as a microsoft research project and was primarily in the dotnet ecosystem it's pretty much only been in the diamond ecosystem whereas dapper kind of grew out of the open source ecosystem with other languages and has a lot of support for other languages as well both have an actor model um and both have this concept of uh kind of abstracting away the persistence layer dapper supports a bit more of the a bit higher number of persistence uh layers than orleans does out of the box orleans can support anything that ado can support it can also support azure storage and a bunch of other things all in the orleans documentation whereas dapper kind of abstracts all that away through almost like a sidecar implementation and like an api set like i said earlier we're talking to the dapper folks we've got a couple different persistence providers for orleans we've got like like i said storage and ado one of the things we kind of flirted with the idea of is maybe like writing a dapper persistence provider so if you're using dapper and you want to use orleans and just sit on top of it you could do that um none of that stuff sets in stone it's all ideas that we're talking about but those but the two teams are definitely collaborating uh there is some crossover and we're really trying to make sure we kind of position orleans at least for now it's something that you know if you're writing.net code it's kind of how you want to distribute your uh your.net processing out or do asynchronous processing okay uh one acronym you said ado several times adm uh uh actual old-school ado uh activated wow yeah activex data objects so like sql like anything anything you can connect an adodb connection to you can put as a database uh for leads so okay yeah yeah and you'll see that in the docs um and then the next and i believe final slide that the pm brought is kind of how we like like i said earlier when we were doing this presentation we were really looking at minimal apis and orleans at the same time kind of an hour-long meeting and what we decided to do what reuben decided to do was to kind of put these two things together in like one slide demo if you really think about it from the top to the bottom you know the very top you know we have to bring in those orleans and orleans hosting uh name spaces uh and then what that brings in is that use the orleans uh extension method that hangs off of the host and at that point you know we're just using local host clustering because this is probably me just getting started there's a concept called a grain factory and the idea of a grain factory is it's essentially a pipe back to that cluster where you can say give me a grain you can give it a good as an identifier or as a string as an identifier and it will basically give you back one uh one instance of that grain uh based on the id that you ask it for this i'll be better when we visualize it with a demo then i would essentially make calls to that grain those are going to be our pc calls back to wherever those grains are running in this in the cluster so remember we talked about that that screenshot earlier where we looked at how the uh uh how this how there's a bunch of different silos running inside the cluster your object could be running on machine a machine b air machine 423 uh the the problem is or the scenario is you're just calling the cluster and the clusters finding that object and giving it back to you and you can make a call to it and then what a grain looks like you would basically inherit from eye grain with string key we've also got gooey key or other types of keys and then you would implement that grain in a class you can see here like a small little hit counter example um and and then you just wire up the the line above where you do the or you do use orleans at that point it would literally find all those grains and put them in the put them in the cluster and you're off and running and that's basically all the wire up you have to do and for those of you who showing my age a little bit here um if you ever did like com or dcom um and you know what i mean when i talk about watching the microsoft transaction server ball spin you know when you when you watch the object spin if you think about orleans kind of like that i know that's a horrible horrible you know topological example um but when you start to look at like the orleans dashboard which we'll see in a minute it sort of reminded me of that you know kind of context you've got you've got this place you put all the objects in the place you call the objects and they scale out magically and it's really thinking about scale out in the context of the objects versus the the the hosting layer of those objects so like rather than think about having your website in four different places you think about having for 14 different instances of your grain object to service requests so okay probably better to look at a demo what do you think i think so although i do i do really appreciate this it's all on one slide this is really nice and this kind of like brings up the why it's kind of nice to have this sort of lightweight model now right it's it's this is actual that like real code that you could run you know exactly on 27 lines of code right and if you think about i think one of the things that's uh that can obviously the complexity of these large apps is you know if you think about just think about yarps purpose in in the world you know europe is just another proxy you put it in front you might have one to a hundred different containers in the back if all those containers are sharing load and doing some you know you know back-end processing how are they going to collaborate well they might all be in an orleans you know cluster together or they might all be clients of an orleans cluster you know using objects that are inside of that cluster so okay so yeah let me go to my screen if i can do that [Music] i will do that on the screen switcher or the screen okay um i guess i have one other or two other community links just because i want to thank these folks um uh thorson hans wrote this great blog post on how to deploy azure container apps with bicep um i'll get that link to john over in the back channel here send that back to john so that's thorston's blog and this was a very helpful blog for me with like looking at the bicep templates uh that you need to write to be able to deploy to aca it's kind of a new service in azure i'm just getting started with it uh and jeff holland was nice enough to answer some of my opinions uh over the holiday weekend as well so i want to thank him um because i never really uh did anything with aca so i want to recommend everybody take a look at this if you're like looking at doing microservices on top of azure container apps this is a really great set of templates to get started with um and then i also want to thank christian uh who did a really great um sample using a let me zoom in a little bit not bad he did a great sample i believe it has a blog post along with it on how to wire up a pretty simple orleans scenario inside of azure container apps as well um i would love it if he put if he's watching if he would put his env file or a sent by his obviously we don't want his storage connection string but a sample in the file so we kind of see what like all the environment variables that he that they had had to weed through his code a bit and get some inspiration from it but uh i definitely want to thank these two for for their work on these blog posts and i'll share that with you as well john so folks who want to start looking at orleans on container apps aren't blocked by me having having not quite figured it out yet but with all that said i want to go over to this desktop over here and i'm sorry let me get rid of my uh kitty uh terminal there so what you'll see is i have on the left i have an app i call translator and on the right i have the dashboard it's essentially the orleans uh dashboard uh which is uh open source project from the orleans community um i can't since i've gone to the different desktop i want to make sure that's what you see here right i do see both of those and for like so we can see them both they're they're both pretty tiny type so if you need here show anything you'll need those gentlemen comes in a little bit uh and i'll zoom in on this one as well this won't get interesting once we start making calls to it um and these are live anybody can hit them uh you know feel free it would actually get interesting to start watching what happens over here so what i'm gonna do here is i'll show you the code here in a minute but think about it from this perspective i've got this web app and what i want to do inside of this web app and this web app and this dashboard are both running inside of my orleans cluster and you'll see here that i have two active silos if i were to click on those and look into one of them you'll see one of them might be labeled web server here we go translator web and then the other one might be labeled like the back end or something like that there's the dashboard so see these running and this looks like it's doing a lot of activity because i've actually left on all of the dashboard grains so the dashboard is actually run by arlene's grants so what i'll do here is i'll go into the preferences and i'm just going to turn those off just because i want to see only migraines so now you see i've only got one activation and it's probably this what what i call the server and we'll look at the code here in a minute but essentially i have two types of grains one of them is a translation server and then the other one is obviously a translator and you'll see here that i've only got one activation and it's that cognitive services translation server and i'm actually using cognitive services on the back back end to go out and do a translation for an individual language but what i don't want to do is have to loop through 103 languages because that would take a lot of time it would also be a lot of processing power because you know i'd have to do one then do the next request and do the next request so what i'm going to do is i'm going to fan that out using orleans so you'll see here as i start to activate these it's going ahead it's making a call out to whatever that uh that the cognitive services api is and i'm just going to add a whole bunch of them and you can feel free out there as well to add and deactivate so i don't think we can see the link big enough so can you see what is it translator yeah i'll drop it into you okay sorry about that right i used signalr demo naming speak sorry so um so if i were to actually take a bigger blob of text here and paste this in and i'll go back over here to the overview and look at the chart so you can actually start to see the requests come in if i drop that in and now you'll see how fast it actually went and for each one of these it was going to go out and make a different actp call that is that is indeed a truism but instead of me having to loop through all of them i'm fanning out and making all those calls at one time and now you'll see as people are starting to maybe make some calls to it we're starting to see that maybe the latency is going to go up because they're making more calls we're doing more more outbound actp calls for that cognitive services uh back end but now you can see really what's happening is we're starting to create more of these objects and and if i were to flip over here now we see here we've got 56 58 different languages getting activated people are using the app and live if i were to flip over here to the translator list i'll look here you'll see here if i look at these silos this first one might be the web server the second one might be the dashboard and you'll see that orleans is randomly placing those translators on those silos as needed you can control that using some of the the grain placement capability that you've got inside of orleans which again is in the docs like i could say i only want to put translators over here i only want to put the server over here i could do you know that kind of control if i wanted to and then you can write your own custom controls if you want to so wow okay so whenever i see demos like this is this costing a million dollars because it's like with that scale what is how does that how does that work uh well with that scale what's actually happening here is these are just oh looks like i might have done something to it uh these are actually just objects that live inside the memory oh or spiking or doing something great what happened on camera uh the the pricing for that one so far has not gotten too bad like i've run this app and i've hit it with a couple of uh load testers and i think i've gotten it as high as something like a five dollar estimate for the month no i haven't put it online and like saw what people could do with it but talking about the topology of it in this particular instance my topology i can look at my bicep file i can show you what that looks like you haven't had anybody talk about bicep yet on the show it's essentially a new uh it's not json not yaml it's a new custom way to write uh templates for azure if i can zoom in on it there we go looking on the screen here see if that looks alright um essentially i'm creating a standard instance of the cognitive services translator which is going to be a per request cost uh looks like somebody might have throttled it um then i'm laying down you know log analytics and application insights those again are you know per request um storage account i'm not really storing a lot of stuff i'm really just using that as my uh gut my clustering what's called your i'm using storage for my clustering so so that the multiple silos can talk to one another through an azure storage account i've got a couple of environment variables and then i lay down a v-net and the reason that i have to lay down a v-net and that's not a v-net that connects back to a network it's simply a regional v-net so that two web apps can basically have a back end now the reason that i need to do that is i need to set my v-net private ports count to higher than two because an orleans cluster requires you know back-end communication between those different resources okay so at this point i would then lay down two web apps i would tell both web apps what their virtual network looks like and they basically start communicating behind one another using that virtual network again that's not a virtual network that connects to like my corporate network that's just a virtual network inside of that region so okay yeah um so you probably want to see some of the code as well sure do so what i'll do here is i'll go into the project and and this is really the project it's uh if you look at my github you'll find it i do not have this orleans azure infrastructure this is just kind of a middleware project i'm working on to kind of make it easy for me to dial stuff in uh but you'll see here that the first thing is if i look here at the eye translation server look at the screen that looks big enough here's my translation server and it says igrain with guide key and really all i do is i pass in google.empty because i really only want one server in the you know one server in the silo so whenever i would make a call to get that server i would i would always task it with empty that's one of the things you'll see in the docs that's kind of a magic string trick but i can also use a string if i wanted to yeah and you see that this is my grain interface and then this is essentially a just a record uh for me to pass back and forth uh um in the in the api um and then this is the response that i would get back when i'm making calls back and forth to the translator this is what my translator interface looks like and i'm defaulting to english because i'm not i'm not doing what anthony chu does in his great example called captioner and interrogating what the incoming language is if somebody wanted to submit a pull request i'd welcome it uh you could add another grain uh figure out what the language is but i'm basically taking the original phrase and the original language code which i presume to be english and then my actual grains are right here the cognitive services translation server and the cognitive services translator and the server really is just keeping a list of a list of the trans the the list of the translations uh languages that i've asked for that's really just a list because later on whenever i uh toggle their status i'm actually going to turn them on you'll see right here toggle active language status i just have a list of strings that i got back from the api the strings are all the different language codes and then i whenever i call translate i'm going to iterate through all of the language codes that i have and that's that grain factory right here inside of my translation server green i'm going to make a call back to the grain factory again and say give me the grain for uh first for spanish give me the grain for french give me the grain for german and then i'm going to use that grain to do the translation of the original string i'm going to win it when all those tasks and when they all come back i'm going to return the list back to the caller okay what i do is i create one object for i get a reference to pardon me uh that object in the in the cluster for each one of the languages at one time so okay so we had this was really interesting because like it when we got everyone pinging it then we got a few timeout exceptions i'm sure would you be able to have multiple of a green type for instance like you've got one grain per language code could you say i can have up to 10 translators per language code that's a great question um and that was actually what i wanted to do before our call i didn't get these all deployed this is what i was going to use azure container apps to do you'll see that i've also got this translation service right here and inside of the translation services worker i basically get 20 languages at random so what i had planned on doing was to create five more web apps and deploy this code to it and basically just have these startup or i could do them as web jobs or i could do them as azure container instances and essentially create one each time and each one would reach out get get 20 languages and then i would have five or six of those running in memory i'd have sex running in memory this is 130 languages so then whenever you would do a call it would fan out to one of those multiple machines but yeah i i presumed our audience would probably bring it down if it's only running on one server well no but i mean like you talked about there's there's you know major games and programs and things running with millions of objects and so you've got to be able to kind of like dynamically scale with all of that yeah yeah exactly the question speaking of scale philip's asking is there limit to how big the state of a grain can be that's a great question uh i do not know i wish reuben was able to to be on the call essentially you think of the grain as like the actor on top of the state and the behavior so um if we were to look at a different piece of code let me actually look at a different one here where i've i've kind of taken reuben's example of a hit counter and in this one i i'm actually storing data using using orleans let me zoom in a little bit and in this case i've got the same kind of thing i just wire my host up to to run in azure because i'm going to run it on top of either aca or web apps um in this case i actually wired up uh azure table storage because i'm going to be storing stuff i'll actually want to store stuff inside of my grain now if i were to open up this grain i've got the site visitor you'll see that in my constructor of this site let me actually get it so you can see everything and the constructor of my site visitor grain class i actually have this thing called i persistent state and i've got a list of site visits here and what that does is every single time the track method gets called i'm actually setting that state and in this case i've just got a list and i'm just adding to it now that list is backed by azure storage so the answer to your question how much state can i store it doesn't matter it depends on how you know how much you want to store in your azure storage account or in your audio database because because the grain is really just a wrapper on top of that storage uh persistence layer okay how how does the latency work because i imagine as you know you get more and more interacting grains and they're all working with each other and and how how does that all kind of like how do you avoid that like we had somebody saying like you know do you get into like n squared problem and that kind of thing that would be a reuben question uh no now i know that there's there's stateful grains and there's also stateless grains um i know that you know you can you can you can balance them you know in independently um for stateless cranes you know you're not going to have a lot of the persistence issues and a lot of that overhead um but for those that you do though the overhead with orleans is pretty insignificant um so okay cool yeah yeah i wish we're gonna talk about that yeah and i i totally appreciate that this you know like you get into complex questions and stuff and there's there's great docs and stuff but this is this is um uh yeah this is really cool okay how do you deal with concurrency and locking like what's used by default and can you change it uh you can change it uh this this is all in in all these docs and this is stuff that i believe reuben's reuben's talked about in all the recent shows that he's done uh he just did a fantastic show from dotnetconf john you might want to get that link from yeah from the from the archives um he he actually closed.net conf this year with a fantastic presentation where he does all these like lines and circle drawings and concurrency is one of the things that he talks about in every one of those presentations so i think he leads with that and he talks about how orleans can literally mitigate a lot of those a lot of those problems so i would encourage you to take a look at that talk um i just i can't go that deep with it um i'm still the pm fumbling around and learning what i can do and how i can break it so all right i'll get that and there's a ton of supercharging your cloud applications with orleans yep look the last thing i would say is i'll share the repo after i get everything in it but i do want to point out that this uh this repo does have out here in it this bicep file and a little setup one ps one so literally you could just clone this thing and once you clone it uh you could run set up ps1 against your azure subscription and it will go out and it will create all of your stuff that way for those of you that are worried about cost like me while you're out there trying this out i can go out here and i can do this and now i apologize i have to kill your demo this is one of the biggest pro tips for working with azure things always use a resource group especially when you're playing and then you can just delete the research group when you're done like this after after i spent way too much money on a you know like i did a demo this was back when we were doing webcams and i was in like finland or and and i gave a presentation and then i got on a plane and then like a month later i checked my azure build i'm like oh no i forgot to delete all those vms and you know so yeah yes pro tip delete but yeah that one that one that one i did not scale out uh i appreciate everybody for load testing it i guess i guess i need to go back to uh figure that out we can come back on at a different time after reuben has had a chance to to make that one more optimal um but what i what i hope to do is to bring this back out uh follow me on twitter and i'll bring this back out and we'll orchestrate some sort of a massive test once i get it uh running on uh aca uh with a bunch of different uh silos uh you know scaled out horizontally then we can really see what we can do okay okay let's look back at your we're trying to think in yours so like in your in the code sure kind of thing where you're fanning out doing this i'm i'm wondering like how you abstract things so that you are like how much your your code is like full of orleans i don't know what i mean like that's right are you abstracted or do you is it just kind of like yeah so let's walk through what that would what that would look like i don't abstract it too far away uh like on purpose just for just for this conversation so do you want let's start at the razer file let's just start that or or our component i guess um so i'll go over here to the web page which is where we would actually make that first call so i'm injecting a grain factory now you know you get that for free because this web app is running in the silo all right like in a client situation maybe we'll come back and do a different one of these where it's the web app is the client the way christian did his sample uh but in my case my web app i say actually running inside the silo with all the grains another reason it probably crashed lincoln down below when this thing loads up what i'm going to do is to get an instance on initialized of that translation server and all i'm doing is i'm saying my grain factory dot get green eye translation server passing do it empty and what that's going to do is that's going to go out to the silo it's going to say give me back the translation server with the good of do it empty and it's going to go oh here it is and it's going to basically go here's a reference to it now you're ready make calls all right the next thing i do is i say get all the languages from that grain now is this uh is this a orleansism at this point it's an orleansism because i'm getting my grain back from the silo from the cluster if you will um at this point i'm really just calling a method on an interface okay yeah um when i toggle the translator again i'm just making just calling a method on an interface because i've already got a reference to that translation grain or that translation server grain and at this point i can just say you know get all languages again whenever i call the translate method at that point i would literally just call translate using that current phrase which is data bound where's my text box right here so it's really just blazer on top now the only thing orleansy in the server side code is this because i have to basically wire up the silo you know i have to have to host the silo um and this is actually uh uh tomahawk says a blazer website is cool uh this is actually not blazer this is blazer server so this is actually blazer server just to be clear um you want to point that out yeah there was a question like hey how does this work with blazer can work with you know blazer front end etc like i don't know the answer to that i believe you would have to make i believe you would either have to make an http call back to the server because you could be your orleans clients inside the trust boundary you got it you you could do signalr you could have a signalrt you could you could do that and that's a that's a really great thing one of my one of my pen chats is uh signalr loves orleans if because if you're if you're if you're you know in the real-time army you know hashtag real-time army uh orleans is a really great thing right below that layer you know if you think about orleans is a thing just below your signal or hubs you know or you know orleans things happen and then you can pop it off to the client using signalr it's a really great combination of things to use but okay so this is your server-side stuff you know this is just i'm making a call to my grain factory there's that now my grains themselves um like we talked about earlier there will probably be a bit of orleans-isms in there because in my get-all languages not really this is me just making a call using http factory http client factory out to uh cognitive services uh this would be an orleansism because i'm gonna be getting i'm gonna be getting the language grain or creating the language grain and see that's the other part that's weird is all i do is i say get green if it's not there it gets created in the silo and it gets then given back to me it does seem like you could like if you cared you could abstract them to more of a service and the service has the grains internally and all that you could yeah you you you absolutely could uh and then this one's one where i'm actually calling as well because i gotta you know make a call to that translator so okay um so question here and i i think this this is decent kind of like to recap it but so what problem did we solve in this demo like what would this what would you do here without orleans etc uh without orleans what i would have done is my index page uh would have essentially had in it um it would have had a call back to a api uh or a signal our hub or something like that and instead of me being able to fan out and execute those those translation processes uh in parallel i would have probably had to translate them sequentially on the server and that would have taken longer that would have been a longer experience to the user also as we saw once we started pinging it with a lot of requests you know we could bring it down um with with orleans i would i would have the capability of being able to scale out those those objects across that cluster and scale scale things either way i wanted to i could scale the ui if i needed to or i could scale the cluster holding all the objects those objects were stateless so essentially i could i could have multiple copies of each of those objects inside the cluster um and that way they could you know one object could service multiple requests i could also go one step further and instead of having one language and one server excuse me one one language grain per language and one language server you know per app i could have set it up and was thinking of setting it up so that i had one language server per remote ip address and one translator per server per language so now we would have a much higher account of grains in the cluster but they would be able to service each individual ip address versus you know having to having to distribute it all out so that's one of the benefits of orleans is you can you can be fancy in how you distribute out your processing versus having to do it all in one place okay a nice thing that philip points out too it's like games is a good use case and and what's one thing you pointed out earlier like here you've got homogenous kind of grains like all your grains are translators but if you had multiple grains where you have players and you know weapons and counts and scores and you know like items and all these different things right then that gets more complex and if if you're able to just say like that's all over new orleans you handle that for me you know i like how you described it too as it's your stateful layer because that's always that's a frustrating thing to wire into applications a lot of the time with asp.net or with web apps because it's always it's stateless and you make a request and response and it's like do i really want to save this out to a database and i do i want to do all this serialization and blah blah blah you know right exactly um i really like the point that uh alexander i hope i said that right made you know the main issue being the signalr as a distributed service needs a back plane you know to sync state that's that's a fantastic point um you know you know back in the day when i started messing around with signalr i wish i would have used these two together a lot earlier because i would probably have used uh probably done a lot more damage i think um and and i think fowler agrees like fowler said that you know the first time you saw the news together he was like oh this is great so um i think we're gonna do some fun stuff here cool um let me see continuing to look through a question from ryan about like a lot of different azure services charged by reads or rights and how how would you like you know how do you manage that from a cost perspective uh that would again i i would have to i would really want to talk to ruben i wouldn't want to speak out of turn on that one um yeah i don't know i honestly don't know when i've spoken to ruben in the past and when we've spoken to the customers that have been deploying we see that most of them this most of the ones we've spoken to who wanted that high throughput were choosing azure table storage uh that seems to be the one that that wins in terms of performance and in terms of cost um but we've also seen some of the iot scenarios would use uh i think it was like streaming and event hubs i think they would also use that uh it's a really great thing for iot scenarios as well because you can imagine a grain is a perfect digital twin for a device and those messages are coming in fast so you'd want to literally have a twin you know one per one per um i've got another demo where we kind of emulate that when we did the top of funnel you know discussions with customers where we've got you know n sensors basically feeding temperature data to a centralized place and we we did that with project high and i crashed my machine it's interesting the whole digital twins thing um being able to pair and so you're programming against like a digital representation of a device which is which is really neat right and and then you don't need we're looking at that when we did kind of an iot focus earlier this year i think in september and you know like cam showed some of this stuff and and his um his let's learn event but you can deploy.net code onto each device or you know which which is some work or if you have digital twins you can just write your code against the twin and the twin just needs to work with the device itself it's a little abstract to think about but it's like really does simplify things quite a bit it does uh the only other thing i wanted to pull up here i just went out to the the github.comforwardslice.net yay forsyth charlene's uh repo and i want to click on samples and i want to say i want to just again i love showing this off um reuben and i went through with ben uh from the team and we did like this huge survey of all the samples over all the different years and versions and we we decided to kind of like really make this like almost like a marquee of like what or what orleans can do uh how you can use early ons in your apps cool things you can build it like microsoft adventure apps uh zork clones uh a chat app because i'm here you know i have a chat a gps app gotta have a gps app if i'm here um so all these different things here's another one uh he made a fantastic um uh hambao uh translator app uh which is really really nifty um all these apps really go through like feature by feature by future by scenario with with orleans and i would encourage you take a look at that i'll grab that link and drop it in uh that would be a great link for folks who want to get started uh just kind of you know partying on our leans and thinking about how they could use it um the sample that i always get lost in is adventure um i could just walk through the code for adventure for hours and hours and hours and get and get inspiration so very cool um let me see i'm trying to see there's there's some good kind of discussion in the chat some people talking about so i'm not sure let me see i'm not i'm getting a parsing error in my brain trying to high cardinality streams in terms of i o i'm not i'm not sure what to i don't i don't know i don't know okay good because i didn't know either i'm sorry um let me see okay here's a random question but this is this is interesting um is there an official way to stream back huge files like a zip and i think this is something actually in dot net 5 and dot net 6 there have been some changes recently with async streams that allow kind of this without allocating there's uh and and i know that it's i would need five minutes to google this up but i know that there are some and i think it would be in the docs but if anyone in the chat wants to to share that out pink fowler about this we just had like this cr really awesome twitter conversation about this using uh web api or controllers i bet he's going to want to do it with minimal and a cancellation token uh there's a way that you can do it um i think it's i think it's new um but i would take a peek at that there's some different things depending on the hosting model where you can basically tell the server here's the file i don't want to care about it you handle it and it basically is going to stream directly from disk or whatever you couldn't you couldn't stream a stream using grpc and know when you were done streaming and then grab it and decompress it was you couldn't do that that's a james king question yeah i think we should ping james newton king and fowler on twitter with that question okay wow okay so this is this is really interesting i've shared out these different links this uh this is a nice thing to to dive into and i think you know actually if you still have your slides i want to go back to your first slide now this is neat because this is a new feature i can change your slides it's a new streaming feature i think this is a good thing the mental model for me to remember here is this kind of like the digital twin is helpful and then that stateful request response and then also i feel like in terms of granularity pardon the pun i guess but going from like controllers and hubs which are kind of bigger down to a grain which can be a tiny little thing like your counter had one tiny it had one you know it has a count and it has a method to increment the count and that's it right right i mean they can be they can be super tiny like if you take a look at some of the samples that are out there you know one of the ones uh let me actually look at it um he's got in one of these he's actually got a thing and a thing could literally be like id name yada yada yada now these are these are the models so these aren't these aren't the grains as much as like these are the models that the grains kind of fly back and forth um if you were to take a peek a step back and kind of look at like eye room grain you know you start to think it's it's a very oopy yep you know and i and um me the decision gets tricky when i when i want to make a decision and this is just something that i'm always thinking about and and pinging reuben like do i want a grain here don't want to model here you know and he'll ask me questions well do you want to act on it or do you want it to act on its own you know and then you start thinking you know um so there's that to think about and then when you've got one grain that will act on see in this case most of these are yeah this is grain acting on objects but he'll have some cases where one grain will act on another grain and that's when you get into the orchestration and things can get a little wonky yeah okay one thing that i must have one thing you probably covered and i was busy looking ch chad or something but in terms of the uh can i run this on like anything can i put it in a container and partly what i'm thinking about is the um communication backend and you mentioned like ado for persistence and that sort of thing so how flexible is this in terms of like could i run this in a docker container and what sort of what are my persistence options there and that's that's great that's great yeah i had had a sample i wanted to run in a docker container that i blew up right before the calls my bad you can run this in docker containers uh like you know christian sample shows uh and a sample that i'll have later on in the week uh so just watch my twitter hopefully you'll retweet it for me i'll have a sample out there that you could literally bicep and deploy uh and actually see some grains running inside of azure container apps so you can run this inside of containers a lot of the customers that we've spoken about uh you know both first party and third party are doing exactly that orleans runs great inside of kubernetes because when you think about the the you know kubernetes built-in dns and routing plus the fact that orleans gives you you know service discovery for free inside the cluster it's pretty great so you know a kubernetes cluster is a great place to run an orleans cluster so okay interesting uh stefan asking about hosting with a like an azure durable function entity that's an interesting amalgamation uh reuben and fowler and the folks who worked on the durable fast framework have actually had a series of conversations about some stuff we could we could do together um i don't know where we are with that at this time um but that's great that's a i'm glad you mentioned that because those are areas where we definitely see cross-pollination uh possibilities um given the fact that with you know if you think about the idea now i know that the orleans can trip folks there's a lot of different open source things that have been contributed by people in the community uh richard askberry and a lot of other folks like christian and so forth um if you look out there you'll find a bunch of different examples of folks being able to do that kind of thing so i mean it's it's rife so okay uh it's an interesting discussion about like and and i think phillip hopefully i'm understanding this right but basically orleans is your internal communication and you're not going to expose like an orleans service anywhere you would have some sort of layer in front of it or you have some sort of and then this is your kind of back end like scale service right right that's a that's a that's a great way to think about it um uh i thought of you know the the midi signalr you know idea that i'm always working on i talked to ruben about it reuben was like orleans would be great for that but your device would be outside the trust boundary and that's when i thought oh lord like yeah because one of the reasons orleans is so quick is the serialization is pretty optimized all right you know with serialization comes security so and that serialization is there any kind of limit does it serialize absolutely any like.net object is it it's it's a binary it's a lower level binary civilization that it's fun to listen to reuben and barry be in the room together okay yeah because i know there's the whole thing barry has goes on and on about the um binary serializer like he still has nightmares about that and exactly very nice okay well the great stuff um let's go back to the one top link that you would people getting started with orleans where would you point them at oh let me get that uh people getting started with our liens um see if i have it in my bookmarks here uh we have a doc effects generated documentation uh site out here um like a lot of the other stuff in orleans it tends to be a bit it's very it goes deep it's very deep um when i got started i would flip between this page and uh the samples and i would literally walk through the samples and just kind of figure out how to do each individual thing that i wanted to learn how to do i am just scratching the surface i'm a very new or orleans user um you know benjamin and uh reuben and richard and a lot of the other folks in the orleans community are super super deep community they love to talk about it there's a getter uh so if you have questions you can go to their getter that's kind of where everybody talks about orleans and asks a lot of questions uh we've got a ton of great information out here we're gonna have more uh we're in the process of thinking about how we would migrate these docs over to docs microsoft com so that's something that we're kind of thinking about doing some customers have asked for that so we're entertaining that idea but we also want to kind of create some docs that are really more problem solution approached and we want to nail those those azure scenarios like web apps azure container apps et cetera et cetera awesome okay i shared that link in the chat and i'm going to go back to just us and i want to end with a great quote here from kevin i think this is i think this sums it up for me too if brady's excited about something i should probably be excited about it too so you're always you're always finding the new things and then uh pointing us in a good direction so i totally appreciate it well that's the best part we're even uh ribbon and the orleans team that stuff is not new it's been around for eight or nine years uh you know we could you know we could have lots of conversations about stuff people are doing with it uh it's a highly powerful tech i would encourage everybody spend a little bit of time over your holiday uh whatever holiday it is uh doing a little hacking on it you got a ton of samples to go party on uh and feel free to send me a pr if you want to improve translator and make sure it scales out better awesome and thank you for helping me crash it that was kind of part of the fun right that takes me back to the old days of like scaling with the signal our demo yeah yeah yeah today yep so awesome okay well i guess we'll wrap up there thank you so much cool thanks everybody take care [Music] so [Music] [Music] you
Info
Channel: dotnet
Views: 7,492
Rating: undefined out of 5
Keywords:
Id: zDLBrQjoOHo
Channel Id: undefined
Length: 70min 35sec (4235 seconds)
Published: Tue Nov 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.