 So I think we're are we live All right Somebody do something Good morning everyone. Thank you for joining us again You have a lot of perseverance if you've returned to your Jeremy and I but Today we actually have somebody that hopefully you will find very interesting because I certainly do and it's Eric D'Andrea so Jeremy Yeah, so I've been looking at to see this talk in person It's excellent presentation if you have if you're used to using spring with many many people aren't used to using spring And you're looking for something new something faster and lighter weight maybe and definitely a more friendly developer experience I think you're gonna like this talk a lot so I'm not a spring developer, but Eric has told me a lot about it and And he has a book that will drop a link for and the comments An existing book and I've been harassing him prior to the show here about finishing the second edition of it So anybody that wants to add comments in there, especially if you're from red hat or somebody that knows Eric please please feel free to do so and We can harass Eric. So with that said Eric Why don't you introduce yourself and tell everybody about yourself and then we can jump right in? Yeah, so thanks for having me. I've been here before in a while, but again, my name is Eric D'Andrea I'm a developer advocate at red hat I actually had the pleasure it was I'm not sure if it was pleasure or pain But I'll call it pleasure of working with Rob in the past 2019 and 2020 when I was part of the same organization as him. He and I used to work together So definitely an interesting experience, I'll say We'll leave it as interesting and people can infer what they want from that Rob dragged you down to Atlanta for something right and we would end up at a steakhouse Yep, and you because you and you had just started right out because you could you contributed to spring for a while, right? Yeah, I was contributed to spring not I didn't work for pivotal at that time but we I worked for it in insurance and financial services and We were like a lot of these large organizations we were consumers of it, but we never gave back And so as actually when spring web flux when spring 5 first came out was it like 2015 26 I don't remember exactly Some somewhere in that in that time frame We were adopting web flux and within our organization and because it was a brand-new stack A lot of the building blocks that had been around like with like spring MVC had been there forever or spring security And a lot of just the foundational stuff and whatnot were there or weren't there So as we were building stuff, I you know kind of went through the process of You're working with our legal team So that we could contribute some of it back You know trying to convince non-technical people that we're not giving away trade secrets your company secrets You know, this is like so like generic It's has nothing to do with insurance and nothing to do with financial services So that was my background there and that's how I got into contributing and then you know It was once I got the approval the first time and I just kind of took it as I had blanket authorization to To do it so I kept contributing for a while So if you were to go to like the spring security GitHub for example and just Google my name or put search for my name You'll find a ton of stuff that were you know, my name has the author tag on a lot of that Which is kind of cool because you you're working in your own code base within your own Organization and you're using some of these things, you know in your IDEs, you know You hover over things you you know spring the spring projects keep the attribution of authors on their in their source code So as you know, you hover over things, you know You start to see it and then like the next spring release will come out And I know my stuff is now in there so now I can like delete my own custom code within my Application and I hover over and I see my name is the author and kind of the upstream community stuff. So it's kind of cool Do you ever get I know there's a lot of folks out there that are working with Legacy do you ever get questions about older stuff that you did Questions about older like I I've done a lot of C++ in the past and I get I Get some amazing questions from stuff from like 20 years ago where people are maintaining something and I must have answered something somewhere because I was on all those Chats at one time and people are like, oh, I got to maintain this and can you help me out with it? I'm like we mean we've moved way beyond that. You're still maintaining stuff like that And I feel bad for the guy and I spend like half an hour Trying to resolve it with him, you know, do you ever get like old legacy stuff? I have what it was interesting when I joined red hat And actually even after I moved out of my the role that I was in the the technical sales role into the role And now I still meet with a lot of different customers. I met with one actually the company that I used to work for before I came here actually two companies before I was there and When I there were still some of the people on the call that I had known when I was in this was like four years after I had left and they were still talking about like the frame I worked on a framework team in a central location and they were still building and maintaining That framework and so like the guy just like said it asked me like a ton of questions about How something worked or whatnot and you know had you know, what could I do to do this on a framework that? I developed like four years before I was even you know There so that that was that was kind of interesting, but I in my career I kind of skipped the whole Java EE thing completely like when I get out of college. I was a I worked for in financial services like I said, but I was doing a lot of swing so like fit client, you know desktop-based applications for trading platforms and You know Java EE wasn't really a thing We had some kind of like early on e-jb's and whatnot But you know I once I started with that we moved right to spring when like spring 2.5 Came out so like I kind of skipped the whole Java EE portal You know kind of every organization that I went to they were just starting a migration away from like web logic portal Or Java EE to what was considered lighter weight in spring at that point in time This was like 2011 2012 and then again in 2015 2016 when I changed companies again So every time I've gone into a new organization It's been we're moving to spring from something else because the something else is Slow fat big takes way too much time to develop against and we need something lighter weight Which is kind of a nice segue into what we're gonna talk about today because in some instances, you know some people might see and Certainly I don't want to throw a spring under the under the bus or anything like that because it's it's very prevalent out there A lot of people use it. It's it's evolved over time There's a huge ecosystem around it but there are people out there especially when you start talking about queuing Kubernetes and running applications and containers and it kind of leads into you know, some of my slides, so I'll Kind of breeze through my slides when I when I start presenting them But yeah, it's kind of the the big elephant in the room and now we need to kind of rethink what we're doing so that we can you harness the power of the the the platforms that we're using today and Build and deploy and run applications the way we're doing with things like cube and Kubernetes and whatnot So I guess let me kind of kind of segues into to my talk a little bit So again, I told you who I was Rob had referenced the book. There's a QR code. You can scan there. There's the link at the bottom there It's free. We do have we have given away lots and lots of physical copies. I think you guys are gonna be at Dev Nexus this year, right? Yeah, I think they'll have physical copies of the booth. I won't be there this year, but they'll have some copies I think Daniel will be there and he'll be signing some some copies as well So get that I don't I'm not part of the organization team this year So I don't know like who's organizing it or what time or what day But but I know that they'll have some copies there as well and it really you know, it I wrote the book because I'll a I'd always kind of wanted to write a book but Be when corkis first came out Like anything that's new you always compare and contrast to things that you already know And so like as you're playing with stuff and you try and stuff out, you know You have I had a huge background in spring. It's like, well, how is this? How is it better? How is it not? How is it different? How is it the same? How easy, you know, can you learn it? So I started playing around with it and writing things down and writing blogs and writing some articles And then my boss was like, hey, you should write a book about it So I I wrote a book about it and it's been hard to write another book because writing a book is a serious time commitment Like this this book I think is about 150 pages and this was like nine months of my life, you know As a full-time job 40 hours a week from ideation to publication, so Definitely a very anybody who like I have an envy for anybody who writes books like an air quotes in their spare time I have no idea how they do that. It's the just I know what it was like to do this and it was a huge time commitment Yeah, well, we were we we work with a couple people that like Andy Black and and Daniel Oh who seemed to have They seemed to make time out of thin air and they work like 24 hours a day. So And they have a couple really awesome books, but so I never was a I started using Java back during EE5 I guess at the end of E5 into E6 and I thought it was awesome because Coming from C++ on the server was it was a horrifying Thing to do and then Java made life so much easier and then Jeremy got me hooked on corkis So I I've only seen a portion of this talk so I can't wait to hear about the corkis versus spring thing because a Lot of the people I know seem to be on spring and now they're telling me stuff about You know why they're not so enamored with it on the cloud for various reasons. So I'm really interested to hear that part Yeah, so this kind of segues into what I started to talk about. So if you think about How old Java is so it's that you know, if we look at the history lesson So it's about 28 years old it turned 28 recently Java EE is 23 years old at this point. So Show my age a little bit Java was invented while I was in college So I was a sophomore or junior in college when Java Java 1.0 first came out So what that meant for my computer science curriculum was we started in Pascal We moved to C and by the time we got to our senior year electives They expected everything in Java yet never had a course or a class in Java nor object oriented programming Like we we were never in my curriculum never even taught like C plus plus or anything like that So like having to like on your own learn object oriented programming Which was like a headache in the first place like when you're from both when you're coming from a procedural language background and just the grasping the The the the methodology and polymorphism and inheritance and all that stuff I just remember racking my brain around that now It's like I can't even think of another way of doing it although with with all the functional stuff that's in there now It's like I I remembered this thing called Fortran that they made us learn a little bit And I could not get a hang of functional programming now. I can't imagine not having it but any event The platform itself not just the language so like when I talk about Java I talk about the whole ecosystem around it not just the language that the JVM in and of itself I mean look at all these other languages that have been spawned that run on the JVM I mean you got groovy, which is a close cousin to Java. You've got Kotlin, which is really taken off Somewhat a close cousin, you know closure scala You get all these different languages that have evolved that Compiled to bytecode and run on the JVM because the JVM is really really good at what it does like the being able to run highly dynamic run times and frameworks and be able to optimize and Reoptimize the bytecode at runtime based on what the applications are doing and the like I said the ecosystem around it the tooling the CICD processes the ID ease the All the DevOps stuff AI all this new Lang chain stuff that that's coming out. I mean, it's it's the innovation Just I know in like the last year is just insane like the like the new stuff that that's coming that that's coming in there But if you think about when it was invented, you know in the 90s that there wasn't there was no cloud that was going to solve all your problems There was no containers. There was no cube, you know, these Applications were run on these huge beefy pieces of hardware like I remember our trading platform ran on these like SunSpark servers with like eight gazillion CPUs and eight billion gigs of RAM I'm exaggerating a little bit, but they they were huge machines and when you needed it when you when it started to not perform well Yeah, we did some some GC tuning and some Tuning of the JVM, but essentially you start to throw bigger hardware at it and that would be how you would scale maybe you would add another machine to your cluster, but you know Everything was always you couldn't grow and shrink and expand it and scale horizontally It was all done vertically by throwing bigger hardware at it and into the point like when I when I moved I worked at Pottenham investments and when I moved to another company We they were doing we were just they were just starting to move to spring from web logic portal And you know back in the day that the developer laptops were Windows XP Which was what a 32-bit operating system So you you couldn't recognize more than three gigs of RAM on a machine even if it had four in it So you couldn't run web logic portal eclipse and outlook at the same time. It was just impossible So you had to like pick pick two or Did you really do all this in one place at work? We would you know, we were deploying I think was we were going to WebSphere, but I don't remember that for sure But you would locally develop on Tomcat right and try to and then like package stuff to go into You know, so you wouldn't even have like a local development environment. Yep Yeah, and there was no like automation like to deploy into a test environment or anything like that You had no like you checked something in you didn't know if you broke something Oh, yeah, until they like went to put it in an integration test environment Then you knew that the thing didn't even compile, right? When you had everybody has snowflake and script, right? So every every and script was completely different. Yeah first week on the job figuring out how to get your thing building, right? First week in first month. Yes I figure I'd build the damn thing But I mean, I remember we had some even at when I was at Putnam we were using I Forget what application server we were using it was the I think Sun one or something like that But I mean we were given our apps are like 10 gigs of heat space Just because we were doing like caching and stuff in the JVM And it was just huge like that the size of this thing was just was absolutely enormous And you updated your JVM what once every three years when a new version came out You updated your the version of your application server every year every two years maybe And then you deployed new stuff what every six months every three months were like the stars had to align on your calendar You know the sixth Tuesday of every month when When when all your teams could come together and then you had to clear your calendar from Friday morning to Monday afternoon And then you had to have hand over this like big document over to your operations team to do the deploy You had to like build the year ahead of time and stage it out in a file share somewhere Or we used to be killing me I went from make files to maven and I loved it and now I'm told that you know gradle's just a Built on maven. I think no, I'm just teasing so I'm just teasing Eric because he likes gradle. Are we gonna see gradle today? Sorry, sorry, that's a different conversation for a different day with a different beer Or was I here yeah, so Part of what started to happen, you know with this whole you know the DevOps You know that any equal to a DevOps started to happen and you know team started They wanted to move faster and more independent mostly more independent not as necessarily faster but be able to be more independent with each other and Force collaboration between between different teams and so Java EE Even though I'm not an expert or anything like that with Javi it moved really slow and the API's that came out of Java EE We're pretty low level right they weren't like higher level building blocks like if you think of something like like Jack's our ass It's just a set of specs or GPA. It's just a set of specs There's really no implementation and it was done that way to so that you could be and again an air quotes vendor neutral But we all know in reality. There was nothing that was ever vendor neutral with Java EE If you wanted to go from web logic to web sphere or to JBoss or whatever It was not an easy or trivial task to do to do that so What started to happen in the industry is the the ecosystem started to band together and Form things that that kind of looked like Java EE or Borrowed things from some of the specs But could do it without these heavy weight and I'm gonna say container I don't mean like Docker container podman container. I mean like Java application container All right, so they you could get this more slid-down version of a Bean but that bean wasn't necessarily an enterprise Java being And you didn't need a full fledged application server to run these applications You could run them smooth came along and said well, why do we even need it? Why do we need to deploy our application into something? Why can't the application itself be enough and embed everything that it needs to do it? And that's kind of where where spring boot was was born from this embeddable that's concept of Embeddable run times and then it just kind of took off for for a long time Until we got to a cube in containers, you know the darker containers now And what did we find out when we started running Java about like 10 years ago in containers? It kind of sucks, right? It's it it's trying to a container needs to be ephemeral needs to start up quickly and it needs to be able to dispose of itself quickly which are three design Considerations that were not part of the design of Java in the first place when it was invented 20 something years ago It was invented to start up run for a really long time and do optimizations and change stuff While it was running and that's kind of the complete opposite of what a container is supposed to do so That's where you started to see like no JS come into play or Python or I'll throw out rust Rob likes rust things like rust and go started to to become popular because They were really fast and really lightweight. But what they lack is the ecosystem, right? They just don't have the ecosystem that Java has out there and so that's Really where corkis was invented. So it wasn't and I'm going to say we I don't include myself when I say We I had nothing to do with the decision. It wasn't like we decided to Oh, there's three Java frameworks out there. We need a fourth one just to to compete it. No, it wasn't the The goal the goal was we need to reinvent Java without having to re-earn a whole bunch of new stuff to make it more Friendly for the challenges that we have today. How are we going to operate applications today? How are we going to deliver applications today? How are we going to build applications today? This short interloop cycle with quick deploys, you know deploy frequently Applications come and go and you'd scale horizontally with all these cloud native principles We we need something that's suited and tailored for that and that that's really where where corkis was born and if you think about the the Slow startup with Java has been you know a problem, but just forgetting just about startup Let's let's talk about warm-up and so after a Java application starts Then you have this warm-up period where the the gvm will actually watch what your application does and the just-in-time compiler will re-optimize your applications bytecode As the application is running so that it optimizes it kind of for that for the hot code paths and depending on the the application that process could take tens of minutes it could be an hour it really depends so You know the faster your application Becomes warm from the jvm and the jits perspective the faster it's going to meet the you know, whatever sla your Your application can provide so if you need to be able to provide 30,000 requests per second as your sla the faster you can get there the better because if you think about a platform like kubernetes I I work with a few customers as well where they were it was a spring boot app and The app was up and then it was a retail company and you know around Um black friday, you know it starts to get bombarded and so there's new instances You know kube would say okay. I need some more instances to handle this load a new instance would start or Start up, but wouldn't be warm yet And so it wouldn't be able to still handle the sla so kube goes Oh, let me throw some more instances out there So now you've got a you know I think it was like 22 instances of this application that was up there But by the time like the 15th through the 22nd instances got up the load had Gone down and now kube says oh You know this application started and say oh nothing to do nothing nothing to see here I've got no work to do let me just go away So it like thrashed their kubernetes cluster and you know when you're running kube in the cloud You know you you're starting new vms and you've got these huge amounts of memory Which you're paying for these instances that are really Not doing much right? I know holly has these talks where she talks about zombie processes and zombie servers that are That are out there just costing people money that don't really do anything So now you've got these these instances and that's what they're doing They start up to find out that they've got nothing to do and then they go away So the faster you can get to this and that that warm-up period the the the better and what we've noticed is One kind of key principle, and I'll talk about this in a second with corkis is the Benefit on the jvm. You know when corkis first came out I think there was like this this thing about like native binary And if you look at the chart here like a native binary if you start a native application You get to that peak sla really really fast, but you pretty much stay there, right? There's really there's a little bit of and i'm using my hands there a little bit of up and down But your your peak throughput is basically the same and it's pretty it's pretty linear And you know there's a little little variation, but for the most part it's pretty linear Whereas in the jvm You you're always going to get better performance and better overall throughput on the jvm regardless of you know corkis spring Micronaut heledon doesn't matter you're going to get better overall throughput on the jvm than you are in native So it's kind of one of those things if if your application is going to be a longer running application It really belongs on the jvm not this native image thing like my personal opinion I think you've probably only got about 20 percent of your use cases that are good fits for native and the rest belongs on the jvm And corkis is going to give you the benefit in this This just-in-time compiler benefit on the jvm worse when spring came out with their native thing All they really did was retrofit the framework so that you can build it into a native image But it really provides zero optimization on the jvm even what they what they call aot and I can I can certainly go into details um a little bit later on When I talk talk about the code so if you think about like what what does a typical java framework do at You've always had this clear separation between What happens at build time and what happens at runtime and it was always pretty pretty black and white right? You your build time was ant maven grid or whatever build tool you're using you build your jar war ear You push it somewhere Artifactory nexus whatever a container registry and then you run the thing and when you run the thing it has to Load all the classes index all the classes generate all the class metadata Then it's going to look for the config files and in spring's case it does a huge amount of annotation scanning and class pod scanning and Building your beans in your application context so that it can finally Build its model of the world then it can start actually doing things And it's at that point that your application is actually ready to serve requests And that's a lot of stuff that happens in you know three four five seconds when a when an application is starting up But what we do and again, we have nothing to do with it With corkis is we kind of flip that on its head because if we think about well The target deployment is cube or containers But not to say that you can't run it on bare metal I mean you can certainly run corkis on bare metal and you get all the same benefits But the the thought process is if i'm going to scale run this thing on cube and i'm going to scale it horizontally Each instance is the same as every other instance. So why should I have to do all that stuff? at startup each time why can't I? Prebake the just in time compiler at build and then so when the application starts up We can just kind of hand the just in time compiler something and say hey, mr. Or mrs. Just in time compiler. I've already done a bunch of this pre-warm for you Why so here's some work that you don't have to do and you get that benefit on the on the gvm? And then the fact that I can build this native binary is almost like a side effect of the design in the first place, right? you know I can Because I've done all this ahead of time processing and I've done all this just in time compile warning of warming now I can just output a native binary instead of a Jar or you know, I don't have the slide in here, but like check pointed restore like on amazon has they have this new They call it crack which they should never let developers name things because crack is Not a good not a good name when you talk about java on crack, but crac is what I'm what I'm talking about Um checkpoint. I think checkpoint did something and restore. I forget the exactly where the acronym stands that's okay eric and uh And in our linux build we have something called pcp so That usually gets some giggles when I Yeah developers are terrible at naming things, right? They should never let developers name stuff Or at least at least get some kind of management approval about the acronym Yeah Another kind of interesting difference is so like we started when I was working in financial services as Webflux first came in we started to see this as well Is you know, webflux wants to harness reactive and what is reactive reactive is really it's a really good programming model when Your application is not cpu intensive. It's more io bound So it's like I need you get a request in that's network requests You need to make connections to data sources or databases or other external things and then your Main request has to wait for that to finish But you're not doing a whole lot of like computation. It's more just waiting on io So this this reactive model is a much better Programming model for scaling now with the advent of loom and java 21 It's still kind of yet to be seen whether this will continue or whether virtual threads solve all problems That's the topic i'm going to avoid for the the purposes of this conversation But you've got this completely different and much much harder programming model in my opinion to to kind of grasp It's like this meant to mentally grasp the reactive programming model is really hard And with something like spring You know, you're going to sit down and you're going to start building an application to solve some business problem Well, you need to make that decision of which programming model before you've written a line of code Right, so you don't quite Understand what problem you might not even have all the requirements for the problem You're trying to solve But yet you've got to pick the best architecture to solve that problem before you even start Where corkis doesn't care like I can mix and match even in the same class it does it just doesn't care Right under the covers. It's smart enough to know what to do How to handle it whether something needs to be on a worker thread or whether it can run on the event thread Or you can you know force it yourself You know depending on what you want to do or what you need to do and it's it virtual thread virtual thread friendly as well So when you start playing with virtual threads, you can mix and match all three in the same class and it really doesn't matter So like people say, oh, I'm just going to mark all my Methods my you know input methods as virtual threads, you know, that's probably a bad idea as well But in any event, you know, we're I think industry the Is still out to lunch on whether you know, whether virtual threads solve all problems because everything else has to catch up You know now that the jbm has it all the frameworks have to have it and everybody's going to upgrade the java 21 to get it This is somebody I spent a lot of time with react.js and other reactive programming model This is a big deal if you're interested in reactive because of course makes it much much easier than any of the other stuff that I've worked with yeah And then you've got the developer piece and I'm gonna I'll do this in the demo But like being able to run and you talk about that interloop process You know a lot of organizations can't measure how Developer productivity like how long does it take from ideation to actually deploying something? What's that interloop process look like like I've got an idea. I'm going to start up my application I need to debug it. I need to You know do all this little testing like being able to have the test my test suite Because everybody always writes tests for everything they have right all the time and they write them before they've written out their code That's just how everybody operates, right? Not nod your head everybody on the on the feed should be saying yep, that's what we do That's what we do. That's what you should always be doing But wouldn't it be nice if as you're writing your code your tests are being run in the background and not your entire test suite But just the tests that are affected by that whatever change you're making Like it's smart enough to understand the relationships between my code and my test So as I change some code, maybe I've got a thousand Tests in my test suite Maybe only two of them fire because only those two tests are affected by the change I'm making So that's it's that's very unique with corkas You know, I'll come in if I'm working on something I'll start the dev mode up at the beginning of the day and I'll Won't start stop it till the end of the day. I go through the entire day. I never restart what the thing that I'm working on So but at the end of the day, it's still java, right? It's not having to learn something new It's all the same things that you're familiar with or it borrows Or implements a lot of the same. It's not fully java ee compliant Like so you're not going to do ejb's or session beans or any of that kind of stuff But specs like jacks rs jpa jta High using hibernate using liquid base flyway Micro profile micro profile kafka micro profile config micro profile Messaging micro profile reactive mess all these things you're going to use all all the same things that you're already And so something I'm going to go into demo, but something I want you to keep in the back of your mind So so why is the smallness important? Right. So from an operational perspective, I've got a landscape and I'm paying I'm just going to pick a million dollars A year as an operational cost of running my java applications What if you could spend half of that and still have everything it would kind of be a no-brainer, right? And actually that number shouldn't be 50. It should be more like 75 But I think people would laugh if I put a slide and say, how would you like to run everything? You're running at 25 of your current costs But what I'm going to do now is I'm actually going to prove that number that 75 That 75 percent number to you through demo and then through some some benchmarking that that we've done here So now I'm going to Jam All right. So what I've got here. So this is actually from my book This example is one of the examples right from the example repository in my book So if you are familiar with the book in chapter four, there's the spring data jpa example here And I've I've updated a little bit. So it's I'm running with java 21 So I can show you what java versions I'm using. Yeah, I'm using the the tenure in java 21 And then for for grawl I'm just using grawl community edition for java 21 You know just upstream community. So I've got a it's a pretty simple application. So I've got spring data jpa I've got an entity class It's pretty it's pretty simple. It's got a couple attributes. I've got a spring data jpa repository class with another attribute. I've got a spring mvc controller with a couple Endpoints, I've got a like a get all I've got a get single, you know based on path parameter And then I've got a a post which can add fruits to the repository and it's all wrapped around a postgres database And it's got a boatload of tests. So what this is um using the latest version of spring boot So it's spring boot 3.2.3. There is um, I'll show you the palm. There's a couple of bugs out there so when 3.2.2 came out native compilation if you're using spring data jpa is busted you can't compile An app a spring boot 3.2.2.2 app that uses spring data jpa to native When 3.2.3 came out, it's still kind of busted But you can fix it by downgrading hibernate and that that it's kind of one thing I like to to talk about too is Like when we talk about hibernate like hibernate is a it's an open source project and it's used by lots other things It's used by spring. It's used by corkis. It's not like there's a corkis version of hibernate And then there's a spring version of hibernate. It's the same hibernate binaries that are out there and In hibernate land like on on maven central. It's just the When you start talking about corkis It's doing a whole bunch of build time optimizations around hibernate and for whatever reason spring boot 3.2.3 the hibernate version that's out there they haven't Fixed it so it doesn't doesn't work in native So you have to downgrade the hibernate version to get it to work Um But in any event that's not a it's not a deal breaker for what we need to do here The other thing that came with spring boot 3.1 is this whole new test containers So when you're doing testing being able to bind and use test containers for standing up services So like in my case this application needs a postgres database so I can create a Configuration class that binds you know with the service connection to a postgres 14 database and then I can Import that in all of my tests so that it'll automatically instantiate a Postgres database for my tests and it'll automatically you know, there's that you know spring I didn't forget what the properties are but the The spring properties I can look in the application email like the spring that data sourced at url Username password all that that good stuff. So when it runs my tests it can it can do that for me So if I run the thing The first thing I'm going to do is I'm going to just bring up the read me here Just to because I forget the command to start the database So I'm just going to start The database in a container It's not pasting there we go Start postgres And then I've already compiled it. So I'm just going to do a java dash jar target And so the application comes up. So the first thing I'll do is I'll just do a couple interactions with it All right, so I'm using HTTP ie I've instead of curl. I like HTTP ie you could use postman or whatever I just like to keep in the terminal. So if I issue a command to get some fruits I've got some fruits there by Look for an apple With the apple if I look for something like a pineapple All right, I get a 404 we can have a 404 204 discussion another time 404 is always the right answer if nothing exists um, so if I want to add a pineapple so I have a Based on file that I've already created that just has the the structure of the payload so I can I can just post that And now I can ask for my fruits again And say I've got the pineapple there and if I ask for the pineapple again I have the pineapple so if we like look at what we did and we compute the rss Up and so rss meaning resident set size of the application Which is the amount of process space that this application takes up You can see if I do the math here. So this is 5 30 4 4 8 into 10 24 About 518 meg. So if we I'm gonna start taking some notes here. So Let's say 5 8 what I'd say All right 5 18 I want to that sound about right for a spring application Spring mbc with spring data jpa roughly it doesn't sound unordinary So the other thing I'm going to do is I'm going to kill my database and restart it So when you start to like benchmark things like looking at the self reported startup time of anything is is pointless in my opinion Right, like if somewhere in here it says, you know, initialized my application is up. Yeah started it in 3.775 seconds like that that's total bull crap for any framework, right? It's So the right way to do it would be to run it a few times and measure time the first request Which is what I'm going to do. So I have a script which which does that So it basically will just run the application wait for it until it finds or is it here until it can actually get a 200 response and then measure the time and then iterate x number of times and then compute some averages While also capturing the rss at that time as well. So if we run that if I run my script here I'm not going to do it 10 times. I'll just do it five times So if I run this I'll call it time to first request and rss Maybe next time I'll just do it three times That's get stuck That's weird What what is your laptop it's I've got a mac m1 m1 pro 32 gigs ram Yeah, the standard config we get yeah, I'm about a year out from refresh. So 4.352 seconds with an rss of 470.3 max, right? So now if we think about native if I want to compile this application to native What is that going to do for us? So this This is going to take my java application. It's going to do some like really aggressive Dead code elimination. So it's going to look at not just my code, but all the libraries that my code uses it's going to anything that doesn't have Like a strict path to it like any fields methods classes anything that's in there that isn't Referenceable isn't statically referenceable It's just going to throw it away and say yep, we don't need that. That's not used You know don't need that and that's not used and it's going to compile it down to a machine specific binary And I kind of started to allude to it's you're You're always going to get better overall performance on the jvm But what the native binary is going to give you it's going to give you a really small footprint So your binary is going to be much smaller It's going to start up really fast and it's going to get to that peak Warm-up because there's really no more jvm you've that technically there is a little jvm There's a little garbage collector in there, but it's not Any of the same garbage collectors that are there in the jvm. You don't have the just in time compiler anymore. It's gone so What you get when it starts up is pretty much what you get through the lifetime of that application And the build process itself is very resource intensive. So like just building one Is gonna you know, this is probably going to take about two minutes and it's going to use I'm going to say between eight and nine gigs of Yeah, I was going to ask you nothing There's no free lunch, right? So Yeah, what am I going to pay for that and the build time resource by? Yep, so I always talk to you know organizations that want to operationalize native with regardless of framework Like if you're Building if you're doing builds for every pull request You probably don't want to be compiling to native in every pull request Especially if you're using cloud-based machines to run your builds because if each build takes nine gigs of heap You better have some pretty beefy machines, which are going to cost you a lot of money So you need to figure out how you're going to operationalize your When do you actually build the native binary at what point in your you've got the sequence of steps from ideation to Production at what point in that thing do you actually build and test because you certainly do want to test the native binary because There are things you can do in java that when you compile it to native just don't work Yeah, I was gonna so is there any Thing that you've seen you know experientially, you know differences between the native build and the jvm build so you know something to think about when people are doing it because I would imagine that it might it's obviously Optimizing completely differently. So You know, are they going to see different Issues or are they going to see, you know, have you seen anything where you had an issue and One build not the other um, so I've seen like so things that you Like things that don't necessarily work So if you are doing like file like referencing files On file systems, well, you better mark those files that if especially if they're part of your application Tell grau vm about them because otherwise they don't make it as part of your Your your application But there are other like apis that and I don't know why they like especially with like files and like reading files It's just one api might work and one api might not Random numbers so you think about like random number you use java, uta random and you Usually you would have like a random like constant in your class well You're probably not going to want to do that in a native binary because If it gets initialized at build time like any public static finals get initialized at build time So now that random seed is initialized once at build time versus using the system clock at runtime. So You might want you know as part of like your workflow your runtime code is where you actually want to create the random versus at like a constant which is Getting initialized at startup time because otherwise the seed is Essentially the time the application was built not the time it was started Which are two very different things which means it's almost like a constant like why have the seed in the first place Right if it's a constant number. So it's stuff like that it comes with with like security So last question when you do the when you're doing the um native compile here It's compiling on an arm m1. Yep that I have to do that separately for an intel. Yep. Yep. So like if I wanted to i'm not doing containers I'm just building like a platform specific binary But yeah, I am on an arm because i'm on a mac m1 It is an arm you if I were to if I had a like a linux box next to me an amd linux box I would not be able to run that binary on it. It's specific So we've kind of gone full circle like java was invented to Because we were sick and tired of having to compile things and write codes specifically for a target platform So java came along we write once run anywhere, but now we can still write once but now we're building for target platforms again because it's Fat and slow, right? So we've kind of gone full full circle So if we look at what kind of we just finished this build it took two minutes and 17 seconds The build took nine point two eight gigs of heap to actually needed nine gigs of memory to do that build And the resulting binary was 143.26 megs So now if I do that same test if I fire at my database and if I do my You know run that time to first request I'll do it. We'll still do it 10 times to stay consistent. You did it five times last time. So Oh, did I do it five times? Yeah, you did. I'll do it five times I'll do it five times All right, we'll stay consistent So now my time to first request is Uh 0.342 seconds and my rss is 171.3 megs a whole lot smaller, right? I would close to a factor of 100 like in terms of startup time and my memory I've shrunk my memory. I can't do the math in my head, but by a lot Which is called a lot 170 compared to for that But my the cost of that was two minutes of build time instead of a few seconds and nine gigs of memory to to get that so I'm not going to run the app and and do mean or actually yeah, maybe I'll run the app again So now if I run the lifetime of using that in production that's going to be significantly different. Yeah So now if I run the app and I run those same requests, which I have a script Which will just run the request the same requests I did by hand just so you don't have to watch me tight Then if I look at the rss of this application again I've got 176 448 into 1024 is 172.3 2.3 megs So we've gone from 518 to 172 And you notice like the difference in rss while using it versus just a startup isn't a whole lot different So it's it's not shrinking and growing like a typical java application would So now let's do something quite let's do something interesting here So i'm just going to reorder some of my tabs just so I can close down a bunch of stuff Close tabs to the right. So I'm going to do a little bit of surgery here and this is when I tell people Okay, I'm doing spring and I want to learn corkis. How would I do a conversion? This is not the way that I recommend to do it um This is like the demo the like the the whole world of demos so What we're we only have till the top of the hour, right? So now you can you can feel free to go over. Yeah, I've still got some slides though So I'm going to cheat a little bit. So usually I would go through and hand do this, but I'm just going to It's getting recorded on youtube so yeah, I mean I know some people will drop because they only have an hour but feel free to go over if you want to get it all on there Yeah, I mean, I'll probably go over a little bit, but just I'll save a little bit of time I'll just kind of put in I would normally just go through like Dependency by dependency and change it and update it But I'm just going to throw it in there and I'll just I'll walk you through it real quick So I I changed a bunch of the dependencies. So I've got instead of like the spring framework dependencies I got these corpus dependencies that are in here now Um, I've got the postgres. I've got some container image stuff I've got some j unit and assert j Stuff notice what's gone from here is all the test containers libraries If you if I you know undo what I just did here If you look at some of these dependencies I've got like the test containers dependency. I've got the spring boot test containers I could spring boot starter tests. I've got a whole bunch of stuff. I've actually gotten rid of a lot of stuff here You see all those test containers ones are gone So now if I go here, I should actually be able to start my application Let's I'll do it in maven instead of the cli I'm going to try to start corpus in dev mode And it fails. So why does it fail? Ah, it fails because there's still some code here like every spring application has this main class Which has you know spring boot application on it Don't need that. This is like my favorite part like as like a junior developer and you like write lots of code and you Push it and you go do your code review like oh look at all this beautiful code that I wrote Well, that's more code that you've got to maintain now as like a senior level guy It's like hey look at all this beautiful code that I just deleted and we no longer have to worry about and maintain anymore Like it's it's the best it's the best feeling. So I'm going to delete that Jeremy We got we got to get eric back on In a couple months just to talk about gradle versus maven. So So the other thing I can delete remember all this test containers code that we had to write So this is code like that you wrote to get your tests to work using test containers This is code that will never go to production So this was what a day in your life that you'll you'll never get back again That you that you spent debugging when it didn't work and trying to figure out why it doesn't work It it serves a purpose, but it provides no value to the business right because it never goes to production Well, guess what? I don't need it. I can delete it The only other thing I need to do is I need to change so we're going to use um The cork of dev services to spin up our database for us But what because we're in our tests We're actually using a real database and we're not use it going to use dev mode We cork of system that magic where it's going to spin up resources in production for us So we need to tell it where our data source is it really quick. What is cork of dev mode? Yeah, I'm going to show it to you right now. So cork of dev mode when I fire this puppy up. Hopefully it should go So there's a couple compilation errors In our test. So we will fix the test in a second So the application is up in what's called our dev mode And dev mode means I can make changes live without having to recompile or redo anything. So like if I go back and I run my Curl or HTTP requests, you notice I don't get any fruit. So it's because in spring. Where is it here? My data.sql file, which is what spring data called it where's reactor In cork us it's Import that sql. All right. So now I rename the file and I rerun my htp request And now I've magically got some fruits All right, the fruits are just there it read It it didn't restart my whole application. It like redid some byte code We remember that like zero turnaround product from like 10 years ago It kind of does like live reload and whatnot like like something in a way better way Like I could do like really complex refactorings. I can add and remove dependencies. I can move classes around I can do all kinds of crazy stuff and it just keeps on humming Just keeps going as far as the database And test containers. Yep. So you can see in here When I started it up, you know dev services for default data source postgres started So I'm not running my database, you know, this terminal is blank if I actually look at like darker ps I've got a postgres container that's running cork us just said. Hey, you've got this dependency for postgres And you haven't told me where to connect. So let me go spin up a postgres database for you And bind it to your application automatically Not just for your test But while you're actually doing your local development as well And it does that for other things like Kafka and message brokers and key cloak and a whole bunch of other technologies That are out there Yeah, one of my favorite is for Kafka if you spin up cut it'll spin up your brokers in the background, right? So Kafka is running if you still another quarkus like they were developing microservices We're going to communicate through Kafka You if you pop up spin up another instance of cork us it finds the running one and just Yep, right. So it's so it's aware of the the entire environment, right? It's not just, you know, individual Yep Yeah, so that's pretty cool So now the other kind of cool feature with the dev mode is the continuous testing So I'm going to hit the r key on my keyboard. It says starting tests no tests found Well, that kind of makes sense because we haven't you know, I ripped out the dependencies and I didn't change anything yet So my my tests actually don't even compile Right now. So we can we can fix that. So the first thing we're going to do is we're going to remove all these annotations And I'm going to say at cork us tests and then at test transaction So what test transaction does is each of these tests runs in an isolated transaction So I can modify the data in the database at the end of the test. It'll roll back the the transaction And then I'm going to hit save and you notice as soon as I hit save it's I found a test. I'm going to run the test my test now passes I didn't touch a line of code and I still haven't touched a line of code of the main application like I've still got this JPA repository. I've still got the spring mvc controller class. I haven't touched anything yet So that's that one test and then I've got my controller test. So I can do something similar get rid of all these Get rid of all these annotations here Right cork us tests We don't need this mock mvc thing anymore It's using my keto so now when you're testing the mvc layer It's using object-based mocking using my keto to to stub out the repository. So instead of the spring mock bean I can say inject mock And there's a whole bunch of tests here. I'm just going to I'm going to comment out a bunch of them because For demo purposes, I really only care about showing you one So the only thing I need to change here So instead of using this mock mvc is I need to use rest assured For the the testing framework. So I can say get I just installed some of this AI stuff the other day and it looks like it's Telling me what it's trying to insert what I want to do. Look, that's pretty cool I installed like the the amazon code whisperer is what I'm using And it's like, oh, it looks like you're doing rest assured. Do you want to insert some code here? Yeah, let's insert the code Roots and I can say my status code is a 200 My content type is json It knows what I did. That's awesome. This is very cool So instead of this it needs to be is They got pretty close from hamcrest matches So instead of just one it has to be is And instead of this it should be Is And I can get rid of all this other stuff That's the parentheses and now when I save that And now it ran two tests Two tests run successfully. So now my application is up all the tests pass all the tests are green and I'm good to go And I could run all these same requests again And you'd see all the requests now I don't want to do like rss because dev mode now has started all these containers and it's got a whole bunch of extra stuff So when I do my my Performancing and benchmarks I do I don't want to be in dev mode to do that So I'm going to do a clean package skip tests Now we'll go back and we'll reduce some of these things So corkis It's on the jvm. So now we'll start our database Do a first request Target we did what five times before so Time to first request So our time to first request is 1.817 seconds and our rss is 249 and a half And now if I bounce my database I bounce the database because hibernate is creating the schema and adding data and I want it to be consistent each time I run it So now if I do java.jar I run my app I do my run my requests again this 262464 into 1024 is what 256.3 All right, so let's do a little comparison here I'm going to start the native build while I'm doing that comparison this It's time to talk. So we've got spring 518 Versus 256 So less than half the size right start up time to first request 4.3 seconds to 1.8 seconds less than half the time The startup rss our time to first request rss 4.70 into 249 so almost Little bit bigger than half. So almost almost half the size So we've now we haven't touched a line of code. It's still the same code But we've shrunk it In half right so remember that slide with morpheus saying how do you like to say 50% of your resources? So just in one instance we've made it half as big it starts up More than twice as fast and it uses half the amount of resources so That 50% isn't very far off and I'm I'll show once I'm done with this why 50% is actually not a It's actually saved more than 50% because The throughput what I'm not measuring here is throughput because I don't have a beefy machine to pump lots of throughput through it Corpus is going to give you about four times the throughput as well as you are So that 50% really should be closer to 75 or or 80% So if you look at native we can say build time build rss binary size then I'm the first request rss All using all right. So our build time was a minute 30 a little bit shorter, but Minute 30 our rss 5.3 gigs So we use half the amount of memory that it took to actually build the native binary right We did it a little bit faster And our binary is 82.94 banks in comparison to 143 so we're about half a little bit more than half the small but we used a half Of the footprint to actually do the build And now if I start the app again first request I'm gonna do a five times My time to first request is 0.43 seconds and my rss is 63.6 And bounce the database Now if we run the thing I run my requests 76 8 into 10 24 is 75 max oops I'm ag so Minute 30 so 0.43 seconds into 0.3 So It was actually a little slower but the memory footprint 63 into 171 so half the half the size roughly So let's skip that. I know we're running out of time here. So let's Yep, I am using Java 21 someone else So, you know, I kind of showed it on my machine Which is a completely uncontrolled environment, right? But there's plenty of other benchmarks that are out there So like the top left here was from tech and power and this was from this past October October 17th. I think it was when it was when it was run You can say cork us up at the top But then you've got helodon then you've got mic or not And then you've got spring down at number eight which like less than half the the performance Of cork us but what it's actually interesting. We run in the red hat performance engineering lab We again, I'm saying we I have nothing to do with it, but we run benchmarks against Competitors and whatnot. So this I ran this I actually did run this About a week and a half ago. So it's spring boot 323, but it's cork us 3.8 that one which is one minor release earlier than this But what's interesting is if you start to look at like time to first request on the jvm You're getting less like 41 percent the cork us app is starting up versus the spring app And similarly on native, you know time to first request in in the benchmark like 10 percent So it starts up 10 times faster than than the spring version does Excuse me another kind of interesting metric if you look at throughput like I final how much load could each Because so we're talking about a single instance of the application this instance On the cork us can handle almost 30 000 requests per second where the spring is only seven almost 8 000 so You're like 3.75 times more dense Meaning, you know, it can one instance can handle almost four times the load of another instance. So four instances times each instance is half the size. That's what eight so my Slide about how do you like to say 50 percent? It really should be how would you like to save 87 percent of your your cloud resources, right? It's the the number is kind of kind of kind of proved that The other thing that's really interesting and it kind of goes back to my point where The benefit that you're getting with cork us just on the jvm versus spring when they when they brought in the native is mostly Just to get native to work because you look at the throughput and native versus jvm on spring It's you get a little bit more on the jvm But there's not a huge benefit like there is if you look at cork us as a huge difference in throughput between jvm and native And when you start talking about density So this is when your application is at its kind of its max throttle How many ins how much memory is it actually using based on the load that it's handling and in this case? Like for every megabyte of memory that the application was taking The the cork's version is serving almost 70 requests where the spring is only serving 60 or 17 if you round up And it's looks pretty it's pretty consistent in jvm and in native. So you're you're getting Over four times the density on with cork us than you are with with spring And this is done in a controlled lab environment. That's it's actually not even using containers. It's all bare metal I'm running this in bare metal on the java 17 And if you take those two examples and you like look at the internals of the application so you you say You like decompile everything and look at all your classes and the makeup of all not just your code But all the code of all the dependencies and you look at the makeup of the two applications that were used in that benchmark What you start to see is that the cork is version of it and again I alluded to there's not like a hybrid a cork is version of hibernate and a spring version of hibernate It's the same hibernate binary from maven central that we're talking about here As well as all the other like libraries like jackson and whatnot. It's a lot of the same classes, but cork is doing all this stuff at build time so that your actual end application just has less stuff in it Like 37 less classes 42 less fields and 31 less methods. It's just smaller Like it's just smaller and it uses a ton less reflection if you look at the architecture and the design of the application It just uses it does less and less reflection And when you're seeing something earlier about having less code in your application Yeah, just less code So I think holly talked about this when you had her on last month about the the cost and the carbon You know how much you know, she ran an experiment where she looked at What's the carbon footprint of cork is like what does the framework of choice play in your carbon emissions? Because there are a lot of organizations that are very that they want to be carbon neutral by 2030 or You know, whatever whatever date that they've set So what does the framework of choice play in that process? And they found that first off they needed a smaller instance to meet the same sla with corkis Then they did with with spring so with spring they needed a t2 medium and with corkis They needed a t2 micro But they found that the corkis versions both jvm and native were pretty similar that they used three times less So they outputted three times less carbon footprint than the spring version did and how to measure she I don't remember if she talked about it or not, but there's an art There's a link to an article there that talks about how carbon was measured and what I have no idea. I'm not a Not not my area of expertise, but it was kind of an interesting study and so I guess now, you know you come back to how do you like to say 50 and that's Truly an underestimate in my opinion like it should be closer to 75 or 80 If you went to your boss and said Hey, how would you like to keep doing what we're doing but save 80 percent of what we're spending today? That would be like the biggest no-brainer in the history of earth, right? And so that's that's what I got Wow, thank you very much. It's a great presentation. That's great Yeah, I really like that. Yeah It's really serious to the end before. Yeah, that's that's quite that's pretty impressive there, Eric. I like that You had the test numbers and how I know that you say you wouldn't change the code like that, but you it was a pretty clear case for ease of change in the code over Yeah, and And like I said, I mean part of that what I did there was There are extensions that exist to wrap some spring apis, but it's not intended to To wrap every spring api if you were to build an application from scratch I would not recommend going that approach I would recommend looking you know, what does your application need to do Looking at the guides if you're building rest end points, you know build a jacksrs resource class use hibernate use panache Use Kafka, but it's a good way to bridge and start to get yourself Going and in some cases you might not have to do a whole lot of Refactoring it really it's like why the architects get paid the big bucks to say it depends like It depends on what you're doing. I do have I can get you a link to there's a I have a a Hands-on lab that people can it's just out on github that they can run that kind of goes through something similar And it uses the migration toolkit to analyze the application And whatnot if you want me to get you that I can bring that up here I'll put the link and we've got a little private chat here. You can put the link out there Throw that in here. I should have put it in as we wrap this up here Jeremy and I will be at dev nexus in a couple weeks for anyone That's going to be there. Please Look us up. We'll probably be hanging around the red half booth. Jeremy might have some fake, you know heavy metal hair on with a guitar or something and And then I I think it's uh the 11th of april Eric Where are we meeting? We're in burlington massachusetts at the boston java users meetup group Gotcha, so erica Invited me to talk about g rpc and i'm gonna do it with corkis because um I he's trying to convince me to fall in love with all things java and uh, I like corkis a lot So we're gonna talk about g rpc with corkis for anybody that's up in that area yeah So If you're at dev nexus, we do have or I won't be there, but they're These rock and roll band stickers that are the that you've seen in my presentation here This guy down here. We've got some new ones that are coming that are making their debut at dev nexus We've got to be rave arm. That's here on this slide And I've got bb king. That's here on this slide Prince It's here on this one and then we've got zizi top. He was back here at the beginning They were back here at the beginning New case for my laptop. Yeah, I can imagine what jeremy's case is going to look like now Yeah, so they'll have all those stickers over at the red hat booth Excellent. Yeah, so somebody somebody rob myself or another red hat will be handing those things out so if you have Yeah, I'm I'm really looking forward to to seeing what you know everything that's there this year and we'll be there the day before during the lab session too, so You know feel free to look us up And in case you aren't familiar with dev nexus, here's a link to dev nexus Dev nexus is a fantastic conference. I think it's the best java conference in the us For sure and it's in Atlanta, which I'm a little biased to that live here But it's also means it's cheap to get to Atlanta. It's easy to get to Atlanta And it's usually it's inexpensive to stay in Atlanta And it's a fantastic conference the only problem with the conference is there are too many good sessions at the same time It's hard to choose right And daniel o who's fantastic and co with the book with eric We'll be doing a quarkus 3 lab on the on the night Oh, awesome. Eighth night. I'm gonna ask you nice All right. Well, thank you very much, eric. I really appreciate it and I I really I really love what you presented today That was that was pretty awesome. Um, I don't again. I've never seen the whole thing all the way through Those are some pretty Impressive numbers. I when you said 50% I was like, is he gonna make 50% or is it gonna be like on the cusp and it was like Very dramatic, so Yep, always a pleasure. I've seen this several times now and I've enjoyed it every time so excellent