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

  Рет қаралды 12,702

Aaron Francis

Aaron Francis

Ай бұрын

An example of how you can make your requests five times faster with Laravel Octane.
Want to support the channel? Please get in touch! aaronfrancis.com/sponsorships
Laravel Octane docs: laravel.com/docs/11.x/octane.

Пікірлер: 100
@Novica89
@Novica89 Ай бұрын
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 Ай бұрын
Hahaha that's my goal!
@_parassolanki
@_parassolanki Ай бұрын
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 Ай бұрын
Thank you!!
@oyewodayo
@oyewodayo Ай бұрын
Thank you for this video. We need more practical real world insight on Octane like this. Please don't stop.
@septimium
@septimium 27 күн бұрын
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 Ай бұрын
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!
@SimoneFolador
@SimoneFolador Ай бұрын
This is a really nice approach! I will definitely consider it in the near future.
@AntonSuprun
@AntonSuprun Ай бұрын
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.
@TheGajos
@TheGajos 5 күн бұрын
Remember that Octane has official support to first-party packages. Other packages may not work or have memory leak.
@phefochis6149
@phefochis6149 Ай бұрын
Love your helpful and interesting content ❤
@KasimSheyi
@KasimSheyi Ай бұрын
Love this explanation👍 You just gained a subscriber.
@aarondfrancis
@aarondfrancis Ай бұрын
Thank you 🥹
@michailgiannopoulos5274
@michailgiannopoulos5274 Ай бұрын
Don't know much how to code but i love watching your videos!
@aarondfrancis
@aarondfrancis Ай бұрын
Oh heck yeah! Glad you're here.
@b3rking
@b3rking 26 күн бұрын
Aaron is sooooo underated
@ErickJeronimo
@ErickJeronimo Ай бұрын
Great content, thanks!
@linuxgeex
@linuxgeex Ай бұрын
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 Ай бұрын
Yup I think so too
@linuxgeex
@linuxgeex Ай бұрын
@@aarondfrancis This shifts the friction towards the good old C20K problem, if you're old enough to remember that one ;-)
@jobayertuser
@jobayertuser Ай бұрын
it's really usefull resources for laravel please make more videos like this
@GulzarAhmed7
@GulzarAhmed7 Ай бұрын
Aaron is best!
@FarazSamapoor
@FarazSamapoor Ай бұрын
This is so cool!
@1234matthewjohnson
@1234matthewjohnson Ай бұрын
interesting to leverage octane like this
@armanazij
@armanazij Ай бұрын
Excellent
@florinmiu469
@florinmiu469 Ай бұрын
This also works for queue workers in a non-octane configuration
@aarondfrancis
@aarondfrancis Ай бұрын
Yup!
@brunoalfred
@brunoalfred Ай бұрын
Just Woow!
@p3p5y2k
@p3p5y2k Ай бұрын
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 Ай бұрын
Correct!
@tanzimibthesam5861
@tanzimibthesam5861 Ай бұрын
Awesome there is a book on Laravel Octane? did you read it?
@aarondfrancis
@aarondfrancis Ай бұрын
Nope! I just stumbled upon this one by accident
@BatmanBruceWayne
@BatmanBruceWayne Ай бұрын
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?
@abdmaster
@abdmaster Ай бұрын
Nice Video. Is there any chance of getting connection memory leak, since we are holding on it?
@aarondfrancis
@aarondfrancis Ай бұрын
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.
@rizqyhi
@rizqyhi Ай бұрын
I wonder can it be used for database/redis connection as well and gained better performance too?
@etc1702
@etc1702 Ай бұрын
Frameworks already use connection pools
@vladogir
@vladogir Ай бұрын
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 Ай бұрын
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 Ай бұрын
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.
@yarrichar
@yarrichar 24 күн бұрын
Is the client thread safe? I think you can have concurrent requests with octane
@ahmad-murery
@ahmad-murery Ай бұрын
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 Ай бұрын
I'm sure that Guzzle handles all of that transparently!
@ahmad-murery
@ahmad-murery Ай бұрын
@@aarondfrancis If so, that will be great. Thanks once again Aaron💯🚀
@titofrezer6201
@titofrezer6201 Ай бұрын
Very good video, but why specific to laravel octane tho? I mean couldn't we apply this with octane also?
@aarondfrancis
@aarondfrancis Ай бұрын
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 Ай бұрын
@@aarondfrancis sorry I wanted to say with out octane?
@digvijayad
@digvijayad Ай бұрын
Any suggestions on running octane on a shared hosting server?
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 Ай бұрын
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 Ай бұрын
Yeah I agree with the other comment. First step would be to move to a VPS.
@Martin-kt8sz
@Martin-kt8sz Ай бұрын
I think I will use octane just because of this 😂 as my app only does http calls (and a lot of them)
@thewizardguy1337
@thewizardguy1337 Ай бұрын
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 Ай бұрын
Yes! Totally possible
@ruslankomlykov9207
@ruslankomlykov9207 Ай бұрын
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 😊
@rcnhsuailsnyfiue2
@rcnhsuailsnyfiue2 Ай бұрын
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 Ай бұрын
I'm certain you could close it from your side but I'm not sure what the specifics are
@stephenjason7575
@stephenjason7575 Ай бұрын
Roadrunner and swoole is not working on Windows please how can solve this problem it requires php 7.1
@stephenjason7575
@stephenjason7575 Ай бұрын
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
@kennedymwenda3357
@kennedymwenda3357 Ай бұрын
Does this mean Laravel is at par with NodeJS or faster when using Octane?
@aarondfrancis
@aarondfrancis Ай бұрын
Impossible to say! Node is just a runtime, Laravel is a full framework
@Cool_Goose
@Cool_Goose Ай бұрын
Woosh
@AksoomHussain7866
@AksoomHussain7866 Ай бұрын
Is it beneficial for the google server apis 🤔
@michaelscofield2652
@michaelscofield2652 Ай бұрын
Isn't this leaking memory? Or does Guzzle clean up it's connections/state at some point?
@aarondfrancis
@aarondfrancis Ай бұрын
Guzzle / curl will clean them up or close them at some point
@silakanveli
@silakanveli Ай бұрын
Did you create that ApiClient as service?
@aarondfrancis
@aarondfrancis Ай бұрын
I'm not exactly sure what you mean "as service." It's just a plain ol class
@silakanveli
@silakanveli Ай бұрын
@@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.
@brunocmesquita
@brunocmesquita Ай бұрын
Sounds irrelevant, but I would love to know what Chrome colorscheme you're using.
@aarondfrancis
@aarondfrancis Ай бұрын
I... have no idea! Haha. Just whatever is standard I'd have to imagine?
@brunocmesquita
@brunocmesquita Ай бұрын
@@aarondfrancis It looks a little different than the standard ones
@LukeCreates
@LukeCreates 28 күн бұрын
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 28 күн бұрын
Um please do and please report back!
@LukeCreates
@LukeCreates 28 күн бұрын
@@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 28 күн бұрын
Thank you! Love to hear that. Keep me posted! 🤞🤞
@user-tb4ig7qh9b
@user-tb4ig7qh9b Ай бұрын
I have a video idea for measure the db pool connection time
@migles1728
@migles1728 Ай бұрын
I only can say, thank you for sahre bro! really cool the video 😎😎👌👌
@adampatterson
@adampatterson Ай бұрын
You had me at 10x faster
@aarondfrancis
@aarondfrancis Ай бұрын
Whew, glad I put that in the title! 5x is laaaaaame
@adampatterson
@adampatterson Ай бұрын
@@aarondfrancis true, I don't get out of bed for anything less than 10x these days.
@abdallakaram5376
@abdallakaram5376 Ай бұрын
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 Ай бұрын
I like that idea!
@abdallakaram5376
@abdallakaram5376 Ай бұрын
@@aarondfrancis Waiting for this surprise to be announced here or on your other links
@CodeX-xyxy
@CodeX-xyxy 6 күн бұрын
Never used octane but sound very buggy thing.all the php stuff created for traditional php architecture
@aarondfrancis
@aarondfrancis 5 күн бұрын
Maybe give it a shot and see! I don't think it's buggy at all.
@sean_reyes
@sean_reyes Ай бұрын
I thought this was the octane video, but retitled.
@aarondfrancis
@aarondfrancis Ай бұрын
Nope! Brand new, just for you
@Kane0123
@Kane0123 Ай бұрын
Haha one secret trick that Java devs don’t want you to know
@aarondfrancis
@aarondfrancis Ай бұрын
It's great when communities learn from each other!
@rustix3
@rustix3 Ай бұрын
So people just rediscovered Web sockets?
@spicynoodle7419
@spicynoodle7419 Ай бұрын
More like HTTP keep-alive
@aarondfrancis
@aarondfrancis Ай бұрын
Perhaps there's a kinder way to have said that? Saying nothing is also an option!
@rustix3
@rustix3 Ай бұрын
@@aarondfrancis Sorry
@mr_don_key
@mr_don_key Ай бұрын
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 Ай бұрын
This is just showing one technique for one situation. I can't cover everything in every video 😂
@ward7576
@ward7576 Ай бұрын
Suffixing with " in a single specific case" would not yield the same amount of engagement, huh
@aarondfrancis
@aarondfrancis Ай бұрын
Dunno
@spicynoodle7419
@spicynoodle7419 Ай бұрын
That's a bad design. Connections to third parties should be handled in jobs, not synchronously in-process
@aarondfrancis
@aarondfrancis Ай бұрын
Eh, not always.
@Cesarxeon
@Cesarxeon Ай бұрын
Laravel solved race conditions
14:13
Aaron Francis
Рет қаралды 14 М.
PHP is the future
34:27
Aaron Francis
Рет қаралды 166 М.
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 50 МЛН
Cody: the AI assistant that actually knows your codebase
10:07
Aaron Francis
Рет қаралды 17 М.
PHP on the frontend! No more Javascript!
14:47
Aaron Francis
Рет қаралды 117 М.
Laravel's secret weapon: macros (watch me code)
23:46
Aaron Francis
Рет қаралды 18 М.
Laravel vs React
9:40
Aaron Francis
Рет қаралды 43 М.
I build a TODO list app with Laravel in 17 minutes.
17:58
Josh Cirre
Рет қаралды 3,1 М.
Laravel: Change Two Symbols to Boost Eloquent Speed
6:34
Laravel Daily
Рет қаралды 81 М.
Laravel + Cloudflare D1 speedrun
7:43
Aaron Francis
Рет қаралды 12 М.
The secret behind FrankenPHP: Will it revolutionize PHP?
12:40
Chris Fidao
Рет қаралды 37 М.
Static Methods in Laravel/PHP: When and How?
10:39
Laravel Daily
Рет қаралды 16 М.
Самый офигенный Сервис 🤣😂
1:00
FunFun
Рет қаралды 3,1 МЛН
Choco Balls??? The Tube Surprise 🍫😮 #Shorts
0:17
Cheesy Adventures Co.
Рет қаралды 7 МЛН
Зу-зу Күлпәш.Түс (16 бөлім)
40:42
ASTANATV Movie
Рет қаралды 821 М.
Сюрприз для матери|смотреть до конца😂
0:45
Он пропал без вести😱
1:00
Следы времени
Рет қаралды 2,1 МЛН
Neden hareket etmiyor #comedy
0:20
Begüm Behlice
Рет қаралды 11 МЛН