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

Поділитися
Вставка
  • Опубліковано 30 вер 2024

КОМЕНТАРІ • 104

  • @Novica89
    @Novica89 5 місяців тому +33

    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".

  • @oyewodayo
    @oyewodayo 5 місяців тому +10

    Thank you for this video. We need more practical real world insight on Octane like this. Please don't stop.

  • @_parassolanki
    @_parassolanki 5 місяців тому +11

    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.

  • @TheGajos
    @TheGajos 3 місяці тому +1

    Remember that Octane has official support to first-party packages. Other packages may not work or have memory leak.

  • @yutoriotsu8848
    @yutoriotsu8848 3 місяці тому

    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 ?

  • @SiriusBlackNuar
    @SiriusBlackNuar 5 місяців тому +1

    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 😊

  • @septimium
    @septimium 4 місяці тому +1

    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! :)

  • @BatmanBruceWayne
    @BatmanBruceWayne 5 місяців тому +1

    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?

  • @yarrichar
    @yarrichar 4 місяці тому

    Is the client thread safe? I think you can have concurrent requests with octane

  • @jit-r5b
    @jit-r5b Місяць тому

    Does it work with laravel http client?

  • @AksoomHussain7866
    @AksoomHussain7866 5 місяців тому

    Is it beneficial for the google server apis 🤔

  • @linuxgeex
    @linuxgeex 5 місяців тому +2

    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  5 місяців тому

      Yup I think so too

    • @linuxgeex
      @linuxgeex 5 місяців тому

      @@aarondfrancis This shifts the friction towards the good old C20K problem, if you're old enough to remember that one ;-)

  • @p3p5y2k
    @p3p5y2k 5 місяців тому +1

    Doesn’t need to be using Octane, but this should also work well for long running PHP processes like a cli command script.

  • @vasiovasio
    @vasiovasio Місяць тому

    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  Місяць тому

      Haha nope, just my teeth! 🙊

    • @vasiovasio
      @vasiovasio Місяць тому

      @@aarondfrancis Wow, DNA Supremacy! ;)

  • @kennedymwenda3357
    @kennedymwenda3357 5 місяців тому

    Does this mean Laravel is at par with NodeJS or faster when using Octane?

    • @aarondfrancis
      @aarondfrancis  5 місяців тому

      Impossible to say! Node is just a runtime, Laravel is a full framework

  • @SimoneFolador
    @SimoneFolador 5 місяців тому +1

    This is a really nice approach! I will definitely consider it in the near future.

  • @michailgiannopoulos5274
    @michailgiannopoulos5274 5 місяців тому +2

    Don't know much how to code but i love watching your videos!

  • @LukeCreates
    @LukeCreates 4 місяці тому

    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  4 місяці тому

      Um please do and please report back!

    • @LukeCreates
      @LukeCreates 4 місяці тому

      @@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  4 місяці тому

      Thank you! Love to hear that. Keep me posted! 🤞🤞

  • @stephenjason7575
    @stephenjason7575 5 місяців тому

    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

  • @michaelscofield2652
    @michaelscofield2652 5 місяців тому

    Isn't this leaking memory? Or does Guzzle clean up it's connections/state at some point?

  • @stephenjason7575
    @stephenjason7575 5 місяців тому

    Roadrunner and swoole is not working on Windows please how can solve this problem it requires php 7.1

  • @AntonSuprun
    @AntonSuprun 5 місяців тому

    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.

  • @Frank-ou2nr
    @Frank-ou2nr 5 місяців тому

    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!

  • @digvijayad
    @digvijayad 5 місяців тому +1

    Any suggestions on running octane on a shared hosting server?

    • @rcnhsuailsnyfiue2
      @rcnhsuailsnyfiue2 5 місяців тому +2

      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  5 місяців тому

      Yeah I agree with the other comment. First step would be to move to a VPS.

  • @Martin-kt8sz
    @Martin-kt8sz 5 місяців тому

    I think I will use octane just because of this 😂 as my app only does http calls (and a lot of them)

  • @jobayertuser
    @jobayertuser 4 місяці тому

    it's really usefull resources for laravel please make more videos like this

  • @mzerone-g6m
    @mzerone-g6m 5 місяців тому

    I have a video idea for measure the db pool connection time

  • @rcnhsuailsnyfiue2
    @rcnhsuailsnyfiue2 5 місяців тому

    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  5 місяців тому

      I'm certain you could close it from your side but I'm not sure what the specifics are

  • @abdmaster
    @abdmaster 5 місяців тому

    Nice Video.
    Is there any chance of getting connection memory leak, since we are holding on it?

    • @aarondfrancis
      @aarondfrancis  5 місяців тому +1

      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.

  • @thewizardguy1337
    @thewizardguy1337 5 місяців тому

    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

  • @tanzimibthesam5861
    @tanzimibthesam5861 5 місяців тому

    Awesome there is a book on Laravel Octane? did you read it?

    • @aarondfrancis
      @aarondfrancis  5 місяців тому

      Nope! I just stumbled upon this one by accident

  • @vladogir
    @vladogir 5 місяців тому

    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  5 місяців тому

      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 5 місяців тому

      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.

  • @adampatterson
    @adampatterson 4 місяці тому

    You had me at 10x faster

    • @aarondfrancis
      @aarondfrancis  4 місяці тому +1

      Whew, glad I put that in the title! 5x is laaaaaame

    • @adampatterson
      @adampatterson 4 місяці тому

      @@aarondfrancis true, I don't get out of bed for anything less than 10x these days.

  • @rizqyhi
    @rizqyhi 5 місяців тому

    I wonder can it be used for database/redis connection as well and gained better performance too?

    • @etc1702
      @etc1702 5 місяців тому

      Frameworks already use connection pools

  • @brunocmesquita
    @brunocmesquita 5 місяців тому

    Sounds irrelevant, but I would love to know what Chrome colorscheme you're using.

    • @aarondfrancis
      @aarondfrancis  5 місяців тому +1

      I... have no idea! Haha. Just whatever is standard I'd have to imagine?

    • @brunocmesquita
      @brunocmesquita 5 місяців тому

      @@aarondfrancis It looks a little different than the standard ones

  • @1234matthewjohnson
    @1234matthewjohnson 5 місяців тому

    interesting to leverage octane like this

  • @KasimSheyi
    @KasimSheyi 5 місяців тому

    Love this explanation👍 You just gained a subscriber.

  • @phefochis6149
    @phefochis6149 5 місяців тому

    Love your helpful and interesting content ❤

  • @titofrezer6201
    @titofrezer6201 5 місяців тому

    Very good video, but why specific to laravel octane tho? I mean couldn't we apply this with octane also?

    • @aarondfrancis
      @aarondfrancis  5 місяців тому +1

      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 5 місяців тому

      @@aarondfrancis sorry I wanted to say with out octane?

  • @abdallakaram5376
    @abdallakaram5376 5 місяців тому

    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  5 місяців тому +1

      I like that idea!

    • @abdallakaram5376
      @abdallakaram5376 5 місяців тому

      @@aarondfrancis Waiting for this surprise to be announced here or on your other links

  • @Kane0123
    @Kane0123 5 місяців тому

    Haha one secret trick that Java devs don’t want you to know

    • @aarondfrancis
      @aarondfrancis  5 місяців тому

      It's great when communities learn from each other!

  • @b3rking
    @b3rking 4 місяці тому

    Aaron is sooooo underated

  • @sean_reyes
    @sean_reyes 5 місяців тому

    I thought this was the octane video, but retitled.

  • @ahmad-murery
    @ahmad-murery 5 місяців тому

    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  5 місяців тому +1

      I'm sure that Guzzle handles all of that transparently!

    • @ahmad-murery
      @ahmad-murery 5 місяців тому

      @@aarondfrancis If so, that will be great.
      Thanks once again Aaron💯🚀

  • @armanazij
    @armanazij 4 місяці тому

    Excellent

  • @DeepStreamBits
    @DeepStreamBits 5 місяців тому

    This also works for queue workers in a non-octane configuration

  • @brunoalfred
    @brunoalfred 5 місяців тому

    Just Woow!

  • @GulzarAhmed7
    @GulzarAhmed7 5 місяців тому

    Aaron is best!

  • @FarazSamapoor
    @FarazSamapoor 5 місяців тому

    This is so cool!

  • @silakanveli
    @silakanveli 5 місяців тому

    Did you create that ApiClient as service?

    • @aarondfrancis
      @aarondfrancis  5 місяців тому

      I'm not exactly sure what you mean "as service." It's just a plain ol class

    • @silakanveli
      @silakanveli 5 місяців тому

      @@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.

  • @ErickJeronimo
    @ErickJeronimo 5 місяців тому

    Great content, thanks!

  • @Cool_Goose
    @Cool_Goose 5 місяців тому

    Woosh

  • @mr_don_key
    @mr_don_key 5 місяців тому

    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  5 місяців тому +1

      This is just showing one technique for one situation. I can't cover everything in every video 😂

  • @Trance_Code
    @Trance_Code 5 місяців тому

    I only can say, thank you for sahre bro! really cool the video 😎😎👌👌

  • @ward7576
    @ward7576 5 місяців тому

    Suffixing with " in a single specific case" would not yield the same amount of engagement, huh

  • @rustix3
    @rustix3 5 місяців тому

    So people just rediscovered Web sockets?

    • @spicynoodle7419
      @spicynoodle7419 5 місяців тому

      More like HTTP keep-alive

    • @aarondfrancis
      @aarondfrancis  5 місяців тому +3

      Perhaps there's a kinder way to have said that? Saying nothing is also an option!

    • @rustix3
      @rustix3 5 місяців тому +1

      @@aarondfrancis Sorry

  • @spicynoodle7419
    @spicynoodle7419 5 місяців тому

    That's a bad design. Connections to third parties should be handled in jobs, not synchronously in-process

  • @Cesarxeon
    @Cesarxeon 5 місяців тому