Spring Office Hours - Episode 42 - Virtual Threads

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] thank you [Music] thank you [Music] [Music] [Music] [Music] thank you foreign [Music] welcome to the spring office hours podcast episode 42 titled virtual threads I'm your host Dan Vega spring developer Advocate at VMware alongside me as always is my friend and co-worker DeSean Carter DeSean how are you doing today I'm here things are great uh that's all I can say just things are moving in the right direction it's a great time to be a spring developer it really is um we have a lot to get to today we got a lot we have some show notes here that we use we have a lot to talk about today um I think one thing I want to address before we kind of jump into the show today is I've gotten a question uh hey I'm looking for the live stream of this podcast where is it the the reason I'm getting this question a lot is because we used to broadcast this live stream to like 20 different channels right it was so much we were we were on so many platforms and so many different channels and so it was easier to find us but it was also confusing right because you never really understood where to tell people to go so right now we are um we are broadcasting this on YouTube to the spring developer YouTube channel which you could find at Spring Source Dev so just look for spring developer you can find it follow follow that YouTube channel this is where we put all of our kind of spring content uh this is the show and that is being broadcast to that channel so you you could find the archives there but you can also find the archives over at Spring Office hours that I owe if you're interested foreign and I knew from Istanbul I think it's new uh or I think they are new Mikhail from Istanbul welcome welcome to the show cool so what have you been up to DeSean we haven't we actually the last couple weeks we went on we had to skip last week because we were both tied up and then two weeks ago uh the great Nate shooter stepped in for you as you were on vacation so it's been a little while what's been going on with you uh I am I'm playing with this thing called kubernetes I've got one two three four five I got five different kubernetes clusters in my home lab uh that I am just playing around and I'm running spring on uh I did a stream with Mark fines last week on get Ops with tap so just kind of yeah different ways that we can deploy kubernetes different ways that we can run spring workloads on them so yeah I'm I'm Dibble dabbling a little bit and then I've been doing a lot of spring shell so I have my handful of spring shell projects that I've been doing I like it because I understand spring I don't have to do bash anymore so I have the one that I use for my uh my initializer plus plus I call it or projects that I do out of start.spring.io I also have one that I use for the show my Spring Office hours helper that does some of the things that we do to get ready for the show and it's just been fun uh taking the latest and greatest and then on top of that I'm working with Mark Pollock on the new experimental project called Spring CLI so cool lots of stuff I've been very active and having lots of fun um for those who don't know about the spring seal I actually had a chance to sit down probably sometime last year with Mark and talk about this project do you want to just kind of give it a high level overview what what it what it is and maybe where it's at as far as the ecosystem goes there's so much to it you know the spring ecosystem is massive and and that's a spring shell uh program but the idea is it's going to be a tool that we can use to help in and around all of our spring projects so some of the things are uh how to create a new project how to add a dependency from the CLI so instead of doing the go to start.spring.io do the generator and explore and copy the block that I need we could do those things from the CLI and then if you uh you know we have these spring Cloud Gateway for example or spring cloud data flow some of these products where you might have some features that get added to to add a filter add a route and have it automatically update your configuration or another like a recipe right yeah it's got It's got these recipes oh that's another thing that it can actually run open rewrite recipes no so yeah there's there's a lot it's still trying to figure out you know what it's going to be when it grows up it's still experimental but it's there's so much there right now it's it's a really fun project so from from what I remember of it and and the things that I've kind of gone through with it you can think of like start that spring.io as a way to bootstrap an application that is really not about code generation that is giving you a starting point in your spring Journey whereas the spring COI if done right and we can add stuff to it and we have all these templates and recipes this is really about like the next step and how to generate maybe say um some code for like a rest API or a graphql API or like you said from the JavaScript World hey I want to add this dependency I npm uh install dependency whatever that is um those are the the types of problems it's trying to solve correct yeah so if you're familiar with spring IO in the and then docs uh you might be familiar with some of the getting started guides yeah so one of the features it has available now is this way of not just generating a project but also generating a project with some getting started context yeah you actually have a working example not just the frame and the dependencies but actual working endpoint for example for spring NBC app yeah so I could see that being used for beginners for like hey I want to I want to kick up a a rest API but also inside of organizations like hey we build a lot of the same apps that kind of look like this and that they're not just starting they have like all of these dependencies and all of these configurations that they they might follow some kind of guide right we have this app accelerator concept which was also created by Mark Pollock hello my head's been racing around this topic the idea I don't take a step back the initializer uh start aspirin.io you can go and Fork that project you can you can use it however you want you can put in your own dependencies you can have your own maps you can put your own versions you can add stuff to it Etc uh I was doing that for a long time I worked with customers that were doing that and but that's where my initial Azure plus plus came from there was a handful of things that I was doing regularly that I didn't want to Fork the initializer project in order to get done so I use this CLI in Spring shell and the native image made it so I could have this kind of first class experience well now the spring system is pretty massive and there's some first class participants in the ecosystem that are actually managed outside of the spring team so one of the other things that the spring CLI is doing is it it opens itself up to other projects being able to integrate so I could say Hey you know spring CLI I would like to add some support for that third party project in that third-party project provides they're getting started their catalog of recipes that's awesome to use their recipes all part of this kind of first class experience yeah a weight of yeah expand and open up and there's other Frameworks and other projects that have similar experiences yeah and this one is just kind of finding which ones we're going to use which ones we're going to adopt but it's really exciting cool love it we gotta comment here it says CLI is love yes that's true I love working with cli's because again it's it goes back to I don't know about you but one of the reasons I got into like programming is just being able to like build stuff for myself like I need to like I need to automate this thing and I could just build something for myself and and that is truly like for you know it could be for others but like hey this is a thing that runs on my computer and does what I tell to do so yeah that's a big that's a big part you know yeah uh yesterday uh and Friday I spent quite a bit of time on this helper uh for our show uh just the idea like hey it's not complex but it's done and it's and I made this and as I was doing that I got to explore I got to grab the latest versions of the other projects I spent time reading the documentation reading the release notes and the changelogs for all these projects that have been released over the last few weeks and that's just exciting I get excited over those kind of things cool well let's talk a little bit about what's going on this week and next week I want to start with uh actually last week so I was in Pittsburgh last week uh had some fun in Pittsburgh was there for just a kind of short trip I was able to have dinner with Cora and our boss Tasha which was really great at this really great Japanese restaurant they had some really fancy uh rolls there I can't remember the name of it now I wish I did um but it was a really good time I was there yeah it was Sushi it was like hand rolls though what is it it's called Sushi no no sushi I remember just not the name of the place um but I was in town for two really exciting um events one was I gave a talk at FedEx Ground their headquarters is there in Pittsburgh and I gave a talk on Spring boot 3 and Beyond uh so this was a lot of fun we talked about like all the new things in Spring boot three 3.1 and guess what's coming in 3.2 so we talked about a lot about something that we're going to talk later today on Project Loom and virtual threads one of the things that came out of that though which was interesting was I got a lot of really good feedback on HTTP interface clients so I got some good questions on that um which prompted me to create a video yesterday so I created actually two one is up right now one is on hey if I'm using an HTTP interface how do I send headers along with the requests so I showed an example of how to send a header through one request or through like every single request and then what I decided to do is I put together a video on like hey let's build out a full crud rest API in one service then create another service and call each of those methods using that interface client because I think a lot of the examples that I've done and that that I see in the in in the community are just like one or two of the the methods I wanted to see like a full crud example of it so I put that together so that should be coming out soon then the next day we had a chance to we had a booth at PNC developer days so PNC has their own developerable conference which is awesome to see if you if you check out my newsletter you can see some pictures from there but they had they rented out the space in the um uh what was it the playhouse it was the Pittsburgh Playhouse it was really cool there they had a ton of developers there they said anywhere from 800 to a thousand in person then they had a whole bunch um off-site like on Zoom or you know virtually um but we had a booth there and it was a chance to kind of talk it to uh everybody at PNC about what VMware tanzu does some of our offerings uh like Taz Cora was giving some really amazing demos on Taz showing how that works and I got a chance to talk to um there were a lot of interns there so a lot of younger developers just kind of very first job didn't didn't know a whole lot about spring or tanzu so they asked a lot of questions about spring and I thought that was interesting because I'm used to getting like beginner questions but these were like even before beginner questions so I had a lot of fun talking to people about like what spring is um and you know how it might benefit them in their career so that was cool so yeah having a lot of fun on the road we're continuing the road show next week in your neck of the woods what are we doing next week next week is kcdc the Kansas City developers conference oh that's gonna be exciting we're doing work yeah yeah so we're we're doing a workshop uh getting started with spring uh this is the kind of second iteration of this particular Workshop that we're doing we learned a lot from the first one as we were talking about before the show uh we have some good plans to kind of revamp that and and kind of fix some things that we weren't happy with last time but here's the thing that was five months ago yeah like forever ago I know I know there's so much stuff has has come since then there's so many new releases oh there's Glenn if anybody knows what is spring it's Glenn maybe we can just like go play golf or something and let Glenn teach this Workshop that would probably be easier Glenn are you gonna be at kcdc no hope so that'd be awesome um so yeah so um this is going to be fun we're putting together the the final touches on that workshop for next week I'm also doing a talk on what's new in Spring boot three so similar one that I gave to FedEx only probably a little bit more concise um yeah and most importantly we are going to get some barbecue there there will be barbecue oh I cannot wait I the last time I was in Texas for work I was down there for a customer meeting we were supposed to go out for barbecue didn't get any barbecue and then I panicked and I got barbecue at the airport because I'm like I gotta have barbecue in Texas and it wasn't good I mean I what I don't know what I expected I know I'm I'm a little bit biased yeah I know I know I that whatever place we went to last year was amazing so the last year was my first time in Kansas City and my first time at kcdc and uh it was just a great conference a whole lot of fun I I just can't wait to be back there so for the speakers dinner we went to barbecue and then we also went to barbecue at my second favorite place your second favorite place then because remember I missed the speaker dinner last week last year because of plain malfunctions and weather and I didn't get into Kansas City until like 1am that day uh it was terrible but I made it so that's a big thing so lucky from Zimbabwe thank you for joining Thomas thank you so much Hey Thomas cool so that's what's happening there um I think what I'll do now is I'm gonna share my screen we have some things to go through before we get into today's topic so let me share my screen the first thing I want to talk about uh as I've been doing the last few weeks is spring one at VMware Explorer this is happening August 21st through the 24th in Las Vegas you can go ahead and register now for spring one what I want to talk about today is the content agenda has been released so if you go down here you can see this button view agenda you can actually go through and start to look at all of the sessions that are going to be available at Spring one so if you don't know VMware Explorer is going to be kind of this massive conference spring one is happening on Day Zero of the conference because Day Zero because we're engineers and we start counting from zero right um so yeah so day Zero is all spring content and so if you want to check out you know all the content that's going to be available there I can finally uh well actually I said on the last show with Nate we were able to announce our talk so I'm doing a talk with Nate shooter on Spring recipes and I'm also able to announce now that I am doing a talk on graphql so spring for graphql we'll talk about um you know making the move to graphql and why you might want to do that so I'm I'm excited about that and I know you have some things going on at Spring one I do but that can wait I have an announcement to make okay this Thomas one of our regulars one of the one of the core members of this community finishes spring Academy and God their spring professional certificate that's great I think that is a great opportunity for us to maybe bring Thomas on the show yeah have him kind of talk about his experience with the spring Academy that would be yeah that'd be great hey I just watched Thomas's recording from I believe spring IO um and that was like his first talk ever I was really impressed with that so awesome job Thomas Ed yeah I'm very very proud very proud he's wonderful and I got to meet him in person that's awesome yes it's a wonderful congratulations Thomas spring dot Academy definitely worth it thank you for a spin and let us know cool it's only been up three Academy started this year right yep started the beginning of the year so it hasn't been around for that long so I think Thomas is a good example of it it doesn't it's not one of those things where it takes you a year to to study and get your certificate uh the spring Academy Works get it done take it for a spin yes lots of high fives and congratulations all the way around all right what do you got going on at Spring one I know you have some things uh I think I'm doing the uh 15 factors on kubernetes nice uh and I think I'm actually doing it multiple times I'm gonna kind of look at it from two different angles I think I'm doing it on the the spring one track and I'm also there it is I'm also going to deliver it oh wait and scaling your spring boot app to zero C I should probably read the agenda yeah it's gonna be fun uh so we'll talk about a little bit about that uh I think next week yes some of the stuff scan zero uh cool those of you that haven't been around I'm a big fan of running on minimal infrastructure cleaning up behind yourself keeping that cloud spend as small as possible and running on Raspberry Pi's cool all right so that is spring one you can check out the agenda register for it now um August 21st coming up pretty quick and we're a little bit two months a little too a little over two months out um again we are gonna try to plan some things for spring one maybe a live session of Spring Office hours we're going to do a 5k on the Strip somewhere uh so we're working on those things we're we also might have some DeSean and I might be doing some things we can't talk about yet but we'll see um we have some exciting things planned for spring one I'm excited register now it's gonna be special like I can I can say that go especially if you're part of this community you'll be well connected to all the secret stuff that we're doing uh but go it'll be fun we're gonna have a good time all right next up we'd like to take a look at calendar.springdata IO this is your place to kind of find out what's happening as far as releases go in the spring Community uh today as we're recording this it is June 13th 2023 we are looking at this calendar Deshawn I know you've done a little homework on the releases here do you want to talk through some things that stuck out to you so the the one of the things about office hours is we want to do a little bit of the work for you so since May 22nd there's I'm going back about these releases spring shell 3.1.0 came out and it was really just bug fixes I had a bug or an issue that I created and I found out hey this issue is not going to be in this release it's going to be in the 3.1.1 release and that that's going to be due on uh June 22nd but this whole idea I've been talking with a lot of customers around uh the value of getting support on Spring right the end of life for 2.7 is coming up in November if I had commercial support then my issue that I raised against spring shell 3.0 that would have made it into three it would have been prioritized into that springshell 3.1.0 release and now since I don't have commercial support now it's it's a lower priority item but it is still going to come it's just it's got that lower priority and that's a question that I've had a lot of times over the past few weeks also r2dbc for Microsoft SQL Server it 1.0.1 release came out just new stuff spring Cloud function 4.0.3 was released and that looks like that was the last component of the spring Cloud release 2022.0.3 uh and there was some breaking cages so if you were coming from Spring Cloud release 2021.x into 2022 there are some breaking changes some things got deprecated some bad things so you might want to take a look at those release notes before you make that move but in that spring Cloud release there's lots of releases from Gateway Springfield contracts bring Cloud config spring cloud kubernetes from cloudcast this is the release train for all those products one of the questions we had last week was around those common libraries spring Cloud Commons 4.0.3 is out there and that's something that you might want to take a look at for a good example of what kind of things could live or should live in a common Library I've done that a lot over the years looked at Spring projects to see how they were set up and how I might want to release my own internal libraries free Cloud streams free Cloud build spring Cloud starter build spring Cloud Netflix all included in that spring Cloud release one of the other things that came out was spring integration AWS 3.0 so this is the first V3 release there is a big change log uh I won't jump into it but there's a lot of things got released uh there was a 2.5 release 2.5.3 or four it was released a few weeks ago so this is exciting integrating directly with the AWS services spring juice this is what we both saw that was kind of interesting spring juice juice for those of you that don't know is also an inversion of control uh container and I actually had some experience running spring and Juice in the same artifact or application Capital application so this is a tool set for using Springwood juice and for using juice with spring but I've lived this stuff I thought it was crazy that we had these both of these iocs in the same project but this release is it's out there and it's just bug fixes but yeah that's a project that I honestly didn't know existed I don't recommend adding juice to your spring projects or spring to your juice projects this is one of those things if it's already there here's a here's a tool set that's going to help uh context propagation this is a big topic we've mentioned this uh with regard to graphql uh in the last few weeks there's lots of updates the big thing that I I got away from this is the better observability getting the observability to propagate through things like graphql when you are aggregating back-end services so after that release came out then we have a bunch of observability releases around micrometer micrometer 1.10.8 specifically calls out its upgrade to the context propagation 1.3 so tons of new releases what I was trying to do is take there's nothing other there's no other like breaking changes in these things uh except for this free Cloud release if you were coming from the 2021 release up those are the only breaking changes I saw so grab them if you're using any of those projects that we mentioned I would love to hear throw it in the chat let us know and that's going to help us decide hey should we talk more about these releases or not that's all I've got from the calendar cool something sticks out for me on tomorrow spring Frameworks 6.1.0 Milestone one uh so that is dropping tomorrow and uh there is a bunch of stuff closed in here we're going to talk about virtual threads later but compatibility with virtual threads open jdks project Loom uh with jvm check checkpoint restore so there's a lot that is going to go into 6.1 it's going to be an exciting release again three dot spring boot 3.2 will be built on Spring framework 6.1 so seeing a milestone there we should see a release candidate later this year post jdk 21 which is September so uh exciting times as you said earlier to be a spring developer I'm gonna put a a little note on some of these questions uh we'll get back to them later but yeah definitely ask your questions in the chat all right um some other things I wanted to talk about with around the web so these are there's things that I found uh whether it was new mostly I find them through Twitter or just kind of coming across these these news items but I thought they would be good things to kind of talk about really quickly uh so growl VM had a release stream today in which they kind of announced their new um release and there are some highlights in here for me so first off if you haven't seen the gravian website in a while there's been an update here and it really looks nice there's a whole bunch of things going on here's an announcement here there's this is now the Oracle kravian so before it was kind of grovium now it is actually the Oracle gravyam and Oracle gravim is available for jdk 17 and jdk 20. free for use in both development and production if you want to you could check out the announcement at crawlvm.org you can also download the new binaries so if you go in here there's a nice downloader you can say hey I want to do Java 17 for Mac OS I can download that uh some highlights of the new release performance improved improvements across the board whether it comes to Startup time memory consumption you now have the option of picking a new garbage collector um Native image is now included in the binary so no longer do you have to go out and install that so that's really exciting uh just making everything so much easier and then they'll be working on you know as this got shipped out the door they're already working on First Class support for things like project Loom and jdk 21 for the next version so I was excited to see uh some of these features drop today I know your big grovium fan to Sean anything stick out for you there uh I I actually love World VM I use it a lot I just ran the I like to use SDK man as well and I ran a bunch of SDK updates just now to see like how long is it going to take before I get it into my SDK man I'll stay tuned for I'm sure it'll be there pretty quick it usually hits pretty quick so usually does yeah so I will leave a link to the stream uh if you want to watch that replay uh it was really great to kind of see them all talking they were all really excited about this release and rightfully so so I'll leave a link to that stream in the show notes um the next thing I wanted to talk about was this article I came across called Spring cloud kubernetes with spring boot 3. um and this is a really good introduction if you are like a lot of us not DeSean included I'm including me in this um who work in Spring Booth so maybe you're new to Spring boot 3 but you use spring boot uh you've heard of spring Cloud you've heard of kubernetes but oh my God how do all these like puzzle pieces fit together uh I thought this was a really good introduction and here it says the main goal of this article is to update you with the latest version of spring Cloud kubernetes project um and really just kind of talking about how to put all these pieces together so I'm Gonna Leave a link to this article in the show notes as well last but not least I have this Twitter thread that I found from Alex you on uh bite bite so they have pipelite as this like architecture YouTube channel and they talk about different uh you know everything architecture and it's not just spring related it's really kind of everything related and he has this really good breakdown of Netflix's overall architecture I'm not going to read everything here but this jumps into like hey on the mobile and website this is what they're using on the front end on the back end and just some highlights for me are on the front end you know communication wise they're using a lot of graphql they use a whole bunch of like Federated graphql apis there they rely heavily on Zuul Eureka Spring boot spring framework and others um yeah and there's a really good um kind of diagram here uh the overall architecture of Netflix so if you ever thought of something as massive as Netflix what does that architecture look like um this was a really good kind of intro and a diagram and you can get um free design free system design PDF 158 Pages by signing up for their newsletter so bye byte goes pretty cool if you've never seen them a quick peruse of that and it's a it's a slightly different way of looking at Netflix from what we saw from Paul Baker on the golden path the spring one so yeah that looks like a really good supplement to what we saw with that presentation yeah so if you haven't seen that um uh go check that out that recording as well we'll see if we can get that in the show notes because it features more of DeSean and that's what we're here to do is give you more um cool so that's really hot that's really all I had is the kind of around the web do you have anything else that you want to talk about you know what I do there's there's a video uh I posted on on Twitter but there's a video that is about it's bone and resilience so it kind of goes outside of spring a little bit running things in production what does it mean to be resilient and it clarified for me the difference between resilience and reliability and or not clarify but it changed the way I'm going to be using those terms going forward uh I got a really good tip from Andrew Clay Shaffer there you go that's it thank you that's the video this time on stage Chicago 2020. uh he's a doctor and the way he describes resilience he describes it using this metaphor or archetype of Bones your bones are constantly being torn down and rebuilt and if you break a bone then it gets extra attention based on the signals that it gets and you kind of map that I can map that to your infrastructure your kubernetes cluster like are things working the way that they're supposed to tear them down stand them back up that's resilience practice of being able to do things constantly all the time that's awesome how did you how'd you end up coming across that did something from that I got that from Andrew Clay Shaffer I got nice lucky I get to hang out with him every once in a while and we were just having a regular conversation and he's like you know what you need to you need to go find this video and I was like you know what I thought about it for days uh and I couldn't find it I I searched I didn't remember the name that he had added but yeah got a note and he hooked me up and it was worth I watched it actually twice I watched it once kind of let it you know wash over me uh and then I put it back in and I went for a a run and listened to it again nice yeah it's one of those it really has changed the way I'm going to be using the words that I use that's awesome cool I'll have to check it out all right um okay with that I think we can move on to our main topic for today let's do it which is virtual threads so for the folks joining us on a live stream here I'm going to share a little something if you are on the podcast don't worry we're gonna do our best to explain to you what I'm sharing just because I wanted to include it as talking points so we make sure that we don't miss anything today so we're talking about project Loom virtual threads um I think before we kind of Kick this this topic off um oh I am not sharing my screen am I let's see what's going on but it's Twitter yeah I don't know why let's fix that sorry I just want to make sure that the folks that are here do get the whole experience so let me re-share sharing our screen sharing a window let's share that one okay so I'm sharing uh some slides again I gave a presentation on um spring glue 3 and Beyond last week we'll be doing this again next week at kcdc been talking a lot about virtual you know virtual threads is a Hot Topic and it's not it's not a spring it's not just a spring thing it's a jdk thing right and so I figured before we talk about kind of what virtual threads are DeSean maybe we could talk about just Mo you know just threads in general in Java so um Java if you don't know is multi-threaded by default um partial you know mostly in thanks to a class java.lane.thread if you don't know this is this class is really an abstraction over operating system threads so your OS has operating system threads this is how it kind of schedules and handles work within the OS so really every thread in Java is essentially a wrapper over an OS thread you often hear these referred to as kind of platform threads as well platform threads are expensive they take a lot of memory they take a lot of time to create and destroy so so that that's where I kind of want to start the conversation anything you want to add to that as far as just what threads are in general in Java no I think that that covers it you know okay um the thread idea I think is a a concept that most people understand and yeah we had this abstraction around the system threads and and now we're going to keep it inside of the jvm so when we add a new thread we're not going to see a new thread when we do psef on our system yep okay so with that kind of backstory let's talk about why we hear the words like project Loom virtual threads what are these things so it's important to understand that project Loom is not just virtual threads project Loom is kind of a collection of uh jeps we'll talk about jeps in a second but if you go to the wiki for project Loom it says project Loom is intended to explore incubate and deliver Java VM features and apis built on top of them for the purpose of supporting easy to use high throughput lightweight concurrency and a new programming model on the Java platform so so project Loom is this collection this mission to deliver these easy to use high throughput lightweight concurrency apps right project Loom is made up of three jeps right now I have these three jeps on screen it could be more but these are the ones I'm going to highlight so Jeff is a Java enhancement proposal this is how new features get into the jdk uh Jep 425 is about virtual threads which we'll talk about Jep 428 is structured concurrency um both of which have been available as a preview since jdk 19 and then uh chip 429 which is scoped values and this was integrated into jdk 20. so I'll leave some links to those uh jeps in the show notes there these what I love about these jeps as they get worked on they they get very detailed so if you're really interested in understanding the Crux of things like the the details the motivation behind this feature read through here um these are really great so that's project Moon project Loom is made up of these uh different gems and then virtual threads as Deshawn said is we're kind of moving away from that abstraction over uh the OS thread so virtual threads again has been there as a preview since jdk 19 this means if you're writing apps in Java 19 or above you can use it but it is a preview feature so you need to use the dash dash enable Dash preview this has been finalized for GDK 21 so we know this is coming in September of 2023 with jdq 21 the important thing is it's no longer linked to an OS thread so a virtual thread is going to be a lightweight throwaway thread that is tied to kind of the Java thread but is not tied to the operating system thread some important things to note is they use the Heap for the stack so this has potential implementation implications for garbage collection they have their own scheduler and they're created for a task and then just allowed to terminate like they can just go away they're lightweight they're throwaway and you don't per you don't want to pool virtual threads these are not meant to be pulled because we no longer need to do that these are lightweight we can throw them away get rid of them do a task goodbye and again not tied to an operating system thread which is a resource you know there is only a finite number of resources when we talk about OS threads so we're no longer running into like are we you know taking up the entire system so that's virtual threads anything you want to kind of add on top of that that uh that last part where the finite resources available to the operating system uh I'm sure many of us have run into that where hey I did I didn't have enough threads in order to do the things I needed to do yep so this there's again we're always faced with these trade-offs and this is the the trade-off we're gonna make that trade for these virtual threads and you brought up the the changes to garbage collection if I'm creating a bunch of virtual threads how are those going to get cleaned up and the implications it's going to have on the Heap and how garbage behaves oh we've also talked about or I've I've had this conversation several times garbage collection is one of those things that it's not one size fits all there's a bunch of options and you should take it for a spin take the other option for a spin because garbage collection that works on application a might not be the best choice for application BC or D I'm glad you brought that up I think for me I don't know about you but for me garbage collection has been one of those like black box magic voodoo things that happen and somehow the engineers that work on this keep making it better and better I don't really understand it and I don't understand how that keeps getting just really really good um so maybe that's something we can explore in the future but in my head I put it in the same box as the aot processing there's you have your application it's it's running in production it may or may not get a better performance with a different garbage collector you know and it really depends if it's just one app okay cool but if you got dozens or thousands of these apps that have uh let's say a four gig uh container and sometimes and I've had this case where just changing the garbage collection allows you to change the size of container that you're deploying yeah it depends on the workload same with aod processing you might get massive benefits by delivering a container that is optimized for that operating system and architecture but again you have to try there's no like guess I can't tell you which ones are going to work and which ones aren't try it and it's worth taking it for a spin and trying something else and visiting your assumptions yep yep okay so I want to expand a little bit on your um you started talking about you know let's talk about it in the content so that's the virtual threads in the context of the jdk like what's a thread what's a virtual thread why do we care as like spring developers and I think that just to kind of expand on your point of how to like thread per request models work um I think it's it's it's an important thing to understand so when it comes to thread per request models in the context of say a spring MVC application it's important to understand where virtual threads are gonna are gonna help us as spring developers so let's say we build this application and it's written in Java in Spring and we're using spring MVC and we're performing some things that are known as blocking operations and what is a blocking operation when I talk to say a database a threat is being used we are talking to a database that thread is going to be in use until that operation that task has been completed um there that is a blocking operation so there are other blocking operations like hey I'm talking to input output stream I'm talking to another service via HTTP I'm communicating with some kind of message broker say through JMS those are all things that are blocking in our applications which means we can't do something else on that thread until that operation has completed right and this is what DeSean was saying before is the way that works is when a request comes in a thread is handling that request on ju in Java right and now that we know that that is just an abstraction over the operating system thread really the operating system thread is now blocked because of that blocking operation that's happening and again there's a maximum number of concurrent threads that are allowed right so when the number of Maximum threads has been reached each subsequent request will need to wait for a thread to be released to fulfill that request so if you've ever been on a server that can take a whole bunch of traffic but then you pile a whole bunch more traffic on it and it just Falls over that's one of the reasons right throughput when it can't be handled so that's really what we're talking about when it comes to thread per request model net when we move to well and I'll back up a little so that's that's how this exists today right this is how we're working with so we have what happens in today's kind of architecture to solve for this problem we have a couple ways that we can solve for it right one is Hardware you can address it by adding more Hardware you can scale vertically adding more memory adding more CPU you can scale horizontally by adding more servers you can also solve this problem by writing non-blocking software and so there's some pros and cons to that but when it comes to Virtual threads we don't need to I mean those are scalability is still going to be a concern right but in this particular scenario when we're talking about a spring MVC app that talks to blocking operations no longer are we going to be tying up operating system threads a virtual thread is going to say oh I need to do a task I'm going to go do it I'm going to be done throw it away lightweight fast we're not blocking an OS thread so we get this really large pool and of virtual threads instead of this finite resource of platform to OS threads what I'm really excited about is we can take advantage of this with little to no code changes on your end so we should see some scalability improvements within your own applications with little to no code changes there's another uh you know slice here that I'm thinking about right now is that hey when I containerize my my Java workloads and I hey I want to run 10 different containers on this node on this host um those again operating system threads like there's only so much that my processor can do in this way with this virtual thread this is going to actually change that Noisy Neighbor issue a little bit it's going to isolate a little bit so the Noisy Neighbor problem is going to go away in some cases I'm just thinking out loud but I'm accepting that this is going to be another area where we're going to find some performance improvements so that idea right there that's something that I'm excited to explore as I have now just deployed a bunch of kubernetes clusters um yeah so again this is going to be really great in scenarios for like spring MVC apps that do that perform blocking operations uh if you're using um some type of messaging or cron scheduled job where hey do this every day that probably is going to talk to a database or someone put output streams so those are the types of apps that are going to benefit from it if you're not using MVC if you're not blocking if it's purely computational you're not going to see any benefit you can still use them but probably won't see a whole ton of benefits so the nice thing about this is you can start doing this today again it's a preview feature in 19 and 20. we don't expect a whole lot in performance changes like obviously some things might change by 21 but most of which is there is going to be how it's going to work right so so you can start test driving this today now this is available um so when we talk about like where are we at with this and I want to talk about loom in a second but where are we at with this spring framework 6 has basic key compatibility so as a preview you can be used with virtual threads setup I have a tomcat virtual thread HTTP example on my YouTube channel on how to like quickly quickly create a new bean and use Virtual threads in your spring MVC UPS going forward you know hopefully we're gonna have um first class support in Spring framework 6.1 spring boot 3.2 so that's exciting uh the other thing I want to bring up is we got a question here and I knew we would get this so I wanted to we always do uh yep where is yeah that was the one all right the first one so I got a question here do you guys think that project Loom will kill the reactive paradigm so as I said there are some ways to um let me just grab my thing we talked about the thread pull thread per request model today and some ways to um basically scale your applications one of which is through reactive programming right instead of Performing these blocking operations reactive programming gives you the ability to say go do this I'm gonna go away and and release that thread let me tell me when you're done with it and then we can handle the the response right so that's that's one thing that reactive programming does does does does does does this kill um that no because there are other things that the reactive programming model does um especially when it comes to Spring web flux when you're working on something like stream based processing and you're working with back pressure this is something that you'll still want to reach for spring webflux for also one of the Jets that we talked about earlier was structured concurrency that is not going to be in jdk 21 this is something that spring webflux also addresses so spring webflux still very much has a place in this story now if you are going forward and project Loom works for you if all you reach for reactive programming for is to improve scalability of your web applications then maybe this is something that you can look at and this is something you can start kicking the tires on so does it replace that one thing that you reached for reactive programming for maybe does it replace everything no and it just there are some pros and cons to each probably it just provides a different scalability mechanism but I would still say that that there's a place for web plugs so that's that's kind of my thoughts on it yeah if you're already doing reactive you're probably not going to see a whole lot of benefit by by undoing it um we talked about the r2dbc driver for Ms SQL um it's a reactive driver right if you've got blocking drivers then there are there are differences there are trade-offs that you're going to make in these different paradigms and solitary turian actually I think gave a really good answer there are categories of applications which benefit from the reactive programming model so I don't think it will die with the introduction of virtual threads yeah great answer yeah so yeah it's there's just different paradigms yep so we got another question here uh so we expect tomcat and spring boot embedded Tomcat to switch to Virtual threads internally in future versions so I don't know that switch completely what I so so what what you have to do today and again I did a video on this if you want to um take advantage of virtual threads in a spring NBC app you need to define a new being that basically tells Tomcat under the hood to now use the virtual thread executor right so to me that seems like more of a configuration thing so I don't know what the answer to this is somebody on the screen team may be able to jump in and say so and I don't know that they know you but um as this is this would to me be through a configuration so I would go into my spring MVC app and I would configure and say Hey I want to use Virtual threads which would in turn underneath the hood tell Tomcat or whatever you know server container you're using hey go ahead and switch to the the virtual thread based executor um so I expect it to be like I said little to no code changes on your end and then probably just a configuration change in your MVC app to say take advantage of virtual threads um so a little comment from Thomas here reactive makes debugging harder I didn't hear much good Arguments for reactive yet you didn't but I think we pointed them out again if you're doing streams-based processing large amounts of data working with back pressure back pressure this is going to help out a lot still um I was searching trying to find I again I don't know exactly but in my my head I feel like the Tomcat is going to switch to using virtual threads by default oh wait here we go says Tomcat 10.1.10 added support for virtual threads I think it'll be the default uh in some upcoming version but I don't know that for sure but yeah you can oh I would have to you know sometimes when I watch these talks too I they're by very smart people when I watch talks I consume what I can can consume and I can't consume Everything at Once Mark Thomas who is A committer on the Apache Tomcat project did a talk at Spring IO and that's where I've learned a lot of my stuff you know my my knowledge from was Mark Thomas uh his his talk at Spring IO you can watch it on YouTube I would go back and watch that he probably mentions something along those lines but like I said I only could take what I got um in that first two passes I think that I've watched it so uh check out his talk and maybe we can learn a little bit more about that there so cool um that's exciting I think uh there there probably is something else to mention um so when we talk about virtual threads like what what has changed in the in the spring framework what what might have to change in your code um again Mark does a really great job of explaining that so maybe go watch his talk on this but there there are some situations that you might run into where some code might have to change um so so so that's something just to think of but in most cases it should be little to no code changes which makes this for me a win-win and I'm excited about that absolutely demo today no I don't think so and again because we're in the because we're in the podcast world now yeah it makes a lot of sense but if we want to uh do something maybe on um some on a live stream somewhere else um that's not the podcast yeah I'd be happy to do that well in that case let me go back to some of these other questions that were asked all right Stig says I'm trying to create a POC on policy-based access management using open policy agent I've created a simple spring API and trying to have Spring Security working with Opa have you tried this previously I have not I believe I do have an example of using open policy agent with a spring boot app using Spring Security and I think I will have to pull that up I know that we have one somewhere in one of the guides so Stig uh I will try to find that and I will I'll push that out onto Twitter uh I'll ask my my friends and we'll we'll get you one of those good question open policy agent and when I first heard about open policy agent it was uh it was it was new and exciting and I was running into a lot of corner cases immediately but now it seems to have some likes I think it's going to be around for a little while good question uh Alexander says hey guys I'm doing a POC on Spring reactor we have a thread that does some processing we want to decouple that by using reactor sinks and flux all of that works fine but exceptions are causing issues it's a very definition of an exception in the middle of the stream processing there is a failure the whole processing stops on error continue and other options do not work any ideas Alexander I think this is one where I'm going to need a little more I have not run into that type of problem it seems like our control Loop is capturing the errors where you don't want it to you want to kind of continue air on air and continue but it's stopping in that case um I've not run into that so Alexander we've we've jumped on streams before we've dreamed on a zoom before I think I might ask you to do the same thing as uh either give me an example repo or reach out and we'll do a zoom and we'll jump into it I don't have all the answers I've not run into this but maybe we can talk through it and figure it out I think those are those are all the ones that I hadn't started yeah we got back to Sandro's and look at this yes we can definitely pair up wonderful awesome well if we have no other questions I think we're coming up against the hour anyways um we'll kind of call it there um if you have questions you can always join us on the live stream as everyone here did today and ask your questions every Tuesday at 3 30 Eastern time on the spring developer Channel with exceptions on travel weeks like next week we are going to be traveling so we're probably going to schedule a stream if I think DeSean you've already scheduled one for next Monday um and I think we need to fix that anyway because next Monday is a holiday here at VMware so we uh may need we'll talk about it okay um so we have another great uh episode coming up on scaling to zero I'm excited about that one I'm excited about kcdc um also if you want to go ahead and check out the archives uh go ahead and head over to springofficehours.io you can ask your questions there if you can't join us on a live stream that's a great place to ask a question we'll see if we can't get to those during a live broadcast and this is a place where you can check out the past archives um so with that I think we will go ahead and call it to Sean I hope you have a great day thank you everyone oh you got one more one last thing no one last thing oh one last thing you're right um kind of a little segment for us to be able to kind of add just one more thing I'm so I funny enough I was telling some people about this last week I got a message on Twitter that uh asked me if I quit YouTube this is because I had not posted a video in two weeks so apparently two weeks is the threshold that you guys have we start to worry we just worry about you we care okay oh it was you was it was it you Anonymous anonymously so I'm gonna I'm just gonna uh go ahead and pimp my YouTube channel um youtube.com danvega I put up a new video this week I have another one coming out later this week so go ahead and subscribe to the channel if you have youtube.com at Deshawn d-a-s-h-a-u-n I have a YouTube channel as well uh I'm only about 1 000 times smaller viewership than Dan uh but um you know baby steps baby steps but solitary turian ask this question does anybody know if Roger Layton will be standardizing native image images building native images like all VM does or some other ways which jvm will be at the bottom of it so you should really join in next week I'm going to talk about scaling to zero and I will talk about the differences of native images and things like crack the check or Consolidated restore at checkpoint there you go uh which does have the jvm at the bottom of it and the whole idea project Laden kind of gives you this balance between what you want to do balance the the the justinheim versus the aot and instead of just having one or the other you can kind of choose where you want to be so that's I think the the goal the best I know of it but yeah you should definitely tune in next week great tune in next week also can't wait to see some of you next week I know Jitter Ted our friend Ted will be in Kansas City can't wait to see some of you DeSean uh thanks again as always and thank you for everyone for showing up to the live stream and we will see you in the next one later
Info
Channel: SpringDeveloper
Views: 1,553
Rating: undefined out of 5
Keywords:
Id: 6QeYgSpntpg
Channel Id: undefined
Length: 63min 6sec (3786 seconds)
Published: Wed Jun 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.