Make faster outbound requests with Laravel (10x faster, actually)

  Рет қаралды 19,664

Aaron Francis

Aaron Francis

Күн бұрын

Пікірлер: 111
@Novica89
@Novica89 8 ай бұрын
Aaron's tutorials are so good that he actually does reverse clickbait and uses "5 times faster" instead of more accurate title which would be "10 times faster".
@aarondfrancis
@aarondfrancis 8 ай бұрын
Hahaha that's my goal!
@_parassolanki
@_parassolanki 8 ай бұрын
I don't even use Laravel at work and still i find your videos valuable enough to watch and learn from it. I love how you describe each concepts in simple manner. Great video as always.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Thank you!!
@oyewodayo
@oyewodayo 8 ай бұрын
Thank you for this video. We need more practical real world insight on Octane like this. Please don't stop.
@septimium
@septimium 8 ай бұрын
This video actually made me want to jump back on an older project, just to switch to using Octane and test it out. You're videos are really inspiring! Thanks! :)
@Frank-ou2nr
@Frank-ou2nr 8 ай бұрын
Really good stuff! Was recently looking into Octane and seeing these kind of examples on how to utilize it in a clever way is very interesting. Thank you!
@AntonSuprun
@AntonSuprun 8 ай бұрын
I haven't worked with PHP for years, and I don't plan to. But I enjoy your videos so much, I still watch them.
@vasiovasio
@vasiovasio 5 ай бұрын
Great video Aaron! This is a Great example, of how small changes has a really Big Impact when they are deployed on Scale! Something that costs Nothing, make it Once and on return the reward is for every single user and request that comes! p.s. polite question - Are these teeth veneers or crowns and if so what brand - eMAX? Your smile is brighter than SuperNova! :)
@aarondfrancis
@aarondfrancis 5 ай бұрын
Haha nope, just my teeth! 🙊
@vasiovasio
@vasiovasio 5 ай бұрын
@@aarondfrancis Wow, DNA Supremacy! ;)
@SimoneFolador
@SimoneFolador 8 ай бұрын
This is a really nice approach! I will definitely consider it in the near future.
@rafamorawiec
@rafamorawiec 3 ай бұрын
Oh my... I love that to use it in my newest project where I have a huge amount of the api connections.
@TheGajos
@TheGajos 7 ай бұрын
Remember that Octane has official support to first-party packages. Other packages may not work or have memory leak.
@michailgiannopoulos5274
@michailgiannopoulos5274 8 ай бұрын
Don't know much how to code but i love watching your videos!
@aarondfrancis
@aarondfrancis 8 ай бұрын
Oh heck yeah! Glad you're here.
@SiriusBlackNuar
@SiriusBlackNuar 8 ай бұрын
I’m even scared to imagine how many Laravel developers have now rushed to connect Octane to their projects and what problems they will encounter due to memory leaks 😊
@b3rking
@b3rking 8 ай бұрын
Aaron is sooooo underated
@linuxgeex
@linuxgeex 8 ай бұрын
This will go a long way towards mitigating the terrible latency and memory costs of using multiple microservices to replace monolithic APIs. Esp where those microservices are implementing zero-trust and operating in tiers. So this is not just a performance feature, but also enabling better security and maintainability by making those microservices feasible at scale.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Yup I think so too
@linuxgeex
@linuxgeex 8 ай бұрын
@@aarondfrancis This shifts the friction towards the good old C20K problem, if you're old enough to remember that one ;-)
@KasimSheyi
@KasimSheyi 8 ай бұрын
Love this explanation👍 You just gained a subscriber.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Thank you 🥹
@BatmanBruceWayne
@BatmanBruceWayne 8 ай бұрын
This might be a basic question, but when an application runs on a standard web server, where the environment is reset with each request, the connections are terminated, correct? I'm curious whether, in the case of using Octane, the connection between the server and the API server remains open continuously. Is that the case? If so, could this have any impact on the server's performance, especially when handling thousands of different requests?
@digvijayad
@digvijayad 8 ай бұрын
Any suggestions on running octane on a shared hosting server?
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 8 ай бұрын
There doesn’t seem much point. Octane improves performance through parallelisation of requests, but it doesn’t increase the overall speed of any one individual process. If you’re at the point where this matters, you’ve already outgrown shared hosting.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Yeah I agree with the other comment. First step would be to move to a VPS.
@phefochis6149
@phefochis6149 8 ай бұрын
Love your helpful and interesting content ❤
@jobayertuser
@jobayertuser 8 ай бұрын
it's really usefull resources for laravel please make more videos like this
@thomaspotterdotexe
@thomaspotterdotexe Ай бұрын
I'm still a little bit confused on how to deploy to vps when using ocatane
@yutoriotsu8848
@yutoriotsu8848 6 ай бұрын
Nice video. Does this have the same effect as I bind a guzzle client instance to the DI container by doing app()->singleton(… if I use octane ?
@DeepStreamBits
@DeepStreamBits 8 ай бұрын
This also works for queue workers in a non-octane configuration
@aarondfrancis
@aarondfrancis 8 ай бұрын
Yup!
@tanzimibthesam5861
@tanzimibthesam5861 8 ай бұрын
Awesome there is a book on Laravel Octane? did you read it?
@aarondfrancis
@aarondfrancis 8 ай бұрын
Nope! I just stumbled upon this one by accident
@ahmad-murery
@ahmad-murery 8 ай бұрын
The question is: what if the connection was still busy? how do we know when we need to create a new one or use existing? I know there must be some sort of property to indicate that but just wanted to bring up some considerations. Thanks Aaron!
@aarondfrancis
@aarondfrancis 8 ай бұрын
I'm sure that Guzzle handles all of that transparently!
@ahmad-murery
@ahmad-murery 8 ай бұрын
@@aarondfrancis If so, that will be great. Thanks once again Aaron💯🚀
@yarrichar
@yarrichar 8 ай бұрын
Is the client thread safe? I think you can have concurrent requests with octane
@rizqyhi
@rizqyhi 8 ай бұрын
I wonder can it be used for database/redis connection as well and gained better performance too?
@etc1702
@etc1702 8 ай бұрын
Frameworks already use connection pools
@1234matthewjohnson
@1234matthewjohnson 8 ай бұрын
interesting to leverage octane like this
@ErickJeronimo
@ErickJeronimo 8 ай бұрын
Great content, thanks!
@titofrezer6201
@titofrezer6201 8 ай бұрын
Very good video, but why specific to laravel octane tho? I mean couldn't we apply this with octane also?
@aarondfrancis
@aarondfrancis 8 ай бұрын
If you have a single long running process, yes! Or you make multiple requests to the same service during a single request, yes!
@titofrezer6201
@titofrezer6201 8 ай бұрын
@@aarondfrancis sorry I wanted to say with out octane?
@thewizardguy1337
@thewizardguy1337 8 ай бұрын
is it possible to use this same approach in a Job, where were using a worker to run the queue also? would be interested in that greatly, since i wont be able to use octane professionally anytime soon heh
@aarondfrancis
@aarondfrancis 8 ай бұрын
Yes! Totally possible
@michaelscofield2652
@michaelscofield2652 8 ай бұрын
Isn't this leaking memory? Or does Guzzle clean up it's connections/state at some point?
@aarondfrancis
@aarondfrancis 8 ай бұрын
Guzzle / curl will clean them up or close them at some point
@michaelscofield2652
@michaelscofield2652 7 ай бұрын
Awesome!
@abdmaster
@abdmaster 8 ай бұрын
Nice Video. Is there any chance of getting connection memory leak, since we are holding on it?
@aarondfrancis
@aarondfrancis 8 ай бұрын
Nah, as long as you're not increasing what is stored over time. In this case the client is set once and then never again. If you had a static array you were pushing to each time then it would grow and grow and become a leak.
@AksoomHussain7866
@AksoomHussain7866 8 ай бұрын
Is it beneficial for the google server apis 🤔
@p3p5y2k
@p3p5y2k 8 ай бұрын
Doesn’t need to be using Octane, but this should also work well for long running PHP processes like a cli command script.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Correct!
@brunocmesquita
@brunocmesquita 8 ай бұрын
Sounds irrelevant, but I would love to know what Chrome colorscheme you're using.
@aarondfrancis
@aarondfrancis 8 ай бұрын
I... have no idea! Haha. Just whatever is standard I'd have to imagine?
@brunocmesquita
@brunocmesquita 8 ай бұрын
@@aarondfrancis It looks a little different than the standard ones
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 8 ай бұрын
If I offer my users an API, can they just leave connections held open on my server like this? From the server side is this kind of behaviour opt-in or out?
@aarondfrancis
@aarondfrancis 8 ай бұрын
I'm certain you could close it from your side but I'm not sure what the specifics are
@kennedymwenda3357
@kennedymwenda3357 8 ай бұрын
Does this mean Laravel is at par with NodeJS or faster when using Octane?
@aarondfrancis
@aarondfrancis 8 ай бұрын
Impossible to say! Node is just a runtime, Laravel is a full framework
@vladogir
@vladogir 8 ай бұрын
With a single request you know whatever you cache belongs to a logged-in user. From my understanding, with Octane it's all shared. So how would you go about caching logged-in user-specific output? One way is using a request ID and then flushing the cache (memorize), creating a cache for a user within Redis or something. But I am curious if you had a nicer approach. Also, given that everything is shared, how would you go about tracking down memory issues - if there is a leak it is bound to keep eating up RAM. Btw, great videos, hope to get my hands on your screencasting course one day 😅
@aarondfrancis
@aarondfrancis 8 ай бұрын
I think you can always just prepend the user ID to the cache key prefix. But this isn't necessarily caching the data, just keeping the connection open!
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 8 ай бұрын
Do you mean memoize, as in memoization? Octane natively resets Laravel’s internal state between each request. Anything else could be in a key/value cache prefixed by the user ID, enforced at application-level.
@silakanveli
@silakanveli 8 ай бұрын
Did you create that ApiClient as service?
@aarondfrancis
@aarondfrancis 8 ай бұрын
I'm not exactly sure what you mean "as service." It's just a plain ol class
@silakanveli
@silakanveli 8 ай бұрын
@@aarondfrancis Like as singleton? I'm trying to figure out how to avoid memory leaks when using Octane. Thinking of starting to use it instead of good old fpm.
@stephenjason7575
@stephenjason7575 8 ай бұрын
Roadrunner and swoole is not working on Windows please how can solve this problem it requires php 7.1
@jit-r5b
@jit-r5b 4 ай бұрын
Does it work with laravel http client?
@armanazij
@armanazij 8 ай бұрын
Excellent
@FarazSamapoor
@FarazSamapoor 8 ай бұрын
This is so cool!
@GulzarAhmed7
@GulzarAhmed7 8 ай бұрын
Aaron is best!
@mzerone-g6m
@mzerone-g6m 8 ай бұрын
I have a video idea for measure the db pool connection time
@markyip554
@markyip554 Ай бұрын
Isn't $client a singleton? Maybe bind a singleton inside service container, instead of making a custom class? Though I understand that's not the focus of this tutorial :)
@aarondfrancis
@aarondfrancis Ай бұрын
yep, not the point!
@LukeCreates
@LukeCreates 8 ай бұрын
Oh my god, I lead an internal Laravel Octane API that gets about 2000/RPS at peak hours, and half of its operations are API calls to a third party. I am going to implement this immediately and benchmark at scale.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Um please do and please report back!
@LukeCreates
@LukeCreates 8 ай бұрын
@@aarondfrancis that’s the plan, currently upgrading our image to attempt to use frankenphp static builds… it’s been a bit of a process haha. Hoping I can figure that out today and then try this tonight. Btw: Love your videos, new viewer here and have been binging. Used to write off PHP like many others but started using modern PHP/Laravel at my new job a couple of years ago and have fallen in love. Our tech stack is Next.js/TypeScript frontends and Laravel Octane backends.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Thank you! Love to hear that. Keep me posted! 🤞🤞
@midgardresident
@midgardresident 2 ай бұрын
have u implemented that?
@Martin-kt8sz
@Martin-kt8sz 8 ай бұрын
I think I will use octane just because of this 😂 as my app only does http calls (and a lot of them)
@stephenjason7575
@stephenjason7575 8 ай бұрын
I could have used frank but it requires docker Ubuntu and that takes space on my pc i just have 117Gb in total and 23 gb available
@adampatterson
@adampatterson 8 ай бұрын
You had me at 10x faster
@aarondfrancis
@aarondfrancis 8 ай бұрын
Whew, glad I put that in the title! 5x is laaaaaame
@adampatterson
@adampatterson 8 ай бұрын
@@aarondfrancis true, I don't get out of bed for anything less than 10x these days.
@sean_reyes
@sean_reyes 8 ай бұрын
I thought this was the octane video, but retitled.
@aarondfrancis
@aarondfrancis 8 ай бұрын
Nope! Brand new, just for you
@theaugmenter
@theaugmenter Ай бұрын
I don't think this is true. Php will leave connections open for the next process to reuse. You can see it in "connection left intact..." log message
@aarondfrancis
@aarondfrancis Ай бұрын
it is true
@brunoalfred
@brunoalfred 8 ай бұрын
Just Woow!
@abdallakaram5376
@abdallakaram5376 8 ай бұрын
very nice my best teacher what about advanced course implement full project about any thing form writing code to test code to upload to server vps it will be paid of course
@aarondfrancis
@aarondfrancis 8 ай бұрын
I like that idea!
@abdallakaram5376
@abdallakaram5376 8 ай бұрын
@@aarondfrancis Waiting for this surprise to be announced here or on your other links
@Trance_Code
@Trance_Code 8 ай бұрын
I only can say, thank you for sahre bro! really cool the video 😎😎👌👌
@Cool_Goose
@Cool_Goose 8 ай бұрын
Woosh
@rustix3
@rustix3 8 ай бұрын
So people just rediscovered Web sockets?
@spicynoodle7419
@spicynoodle7419 8 ай бұрын
More like HTTP keep-alive
@aarondfrancis
@aarondfrancis 8 ай бұрын
Perhaps there's a kinder way to have said that? Saying nothing is also an option!
@rustix3
@rustix3 8 ай бұрын
@@aarondfrancis Sorry
@Kane0123
@Kane0123 8 ай бұрын
Haha one secret trick that Java devs don’t want you to know
@aarondfrancis
@aarondfrancis 8 ай бұрын
It's great when communities learn from each other!
@ward7576
@ward7576 8 ай бұрын
Suffixing with " in a single specific case" would not yield the same amount of engagement, huh
@aarondfrancis
@aarondfrancis 8 ай бұрын
Dunno
@mr_don_key
@mr_don_key 8 ай бұрын
trouble with this is... the connection remains, and many api's usually don't like that (and can possibly ban you for doing so) For php to perform better, use asynchronous calls. And do multi threading on top (more calls allowed, or you can process a call on multiple threads at once), or use micro services. Also your example is purely for api calls, but what about the app itself? that needs to be optimized, e.g. DB queries, not loading things you don't need, the async/threading as mentioned. Most sites won't make api calls to third parties, but are on it's own. Laravel, is default, not very fast,because of the many layers/abstraction (fact), optimizing is required. The ORM does often make queries too complex, thus slowing the proces down (use raw queries when this happen).. I know you are a Laravel Fan, that's fine ofcourse. It's a nice framework, but is just not very fast out of the box. Easy of development is more important than execution speed so it seems. E.g. Symfony is much faster using the same libs (Laravel uses Sympfony libs as foundation,yet heavily modified often -> slower execution) Also running a webserver through php's built in server, is a no no in production. Never do that. (don't say i didn't warn you, when things go south) Use dedicated techniques, like a real webserver with php-fpm e.g.
@aarondfrancis
@aarondfrancis 8 ай бұрын
This is just showing one technique for one situation. I can't cover everything in every video 😂
@spicynoodle7419
@spicynoodle7419 8 ай бұрын
That's a bad design. Connections to third parties should be handled in jobs, not synchronously in-process
@aarondfrancis
@aarondfrancis 8 ай бұрын
Eh, not always.
@Cesarxeon
@Cesarxeon 8 ай бұрын
Make self-healing URLs with Laravel
13:58
Aaron Francis
Рет қаралды 40 М.
The React Interview Questions You need to Know
21:29
CoderOne
Рет қаралды 53 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Laravel + Livewire todo app (and so much more)
16:41
Aaron Francis
Рет қаралды 54 М.
The Most Legendary Programmers Of All Time
11:49
Aaron Jack
Рет қаралды 646 М.
Top 5 Laravel "Bad Practices" (My Opinion)
10:32
Laravel Daily
Рет қаралды 25 М.
Laravel's secret weapon: macros (watch me code)
23:46
Aaron Francis
Рет қаралды 25 М.
A New Drag And Drop Library For EVERY Framework
16:02
Theo - t3․gg
Рет қаралды 179 М.
Laravel Octane: supercharge your Laravel applications
8:34
Aaron Francis
Рет қаралды 52 М.
Supercharge Markdown with Laravel
31:26
Aaron Francis
Рет қаралды 10 М.
What’s Up with Laravel? It’s Everywhere, and Here’s Why!
6:22
The Value of Source Code
17:46
Philomatics
Рет қаралды 217 М.