---
title: "Make faster outbound requests with Laravel (10x faster, actually)"
url: "https://aaronfrancis.com/videos/make-faster-outbound-requests-with-laravel-10x-faster-actually"
path: "/videos/make-faster-outbound-requests-with-laravel-10x-faster-actually"
type: video
author: Aaron Francis
published: 2024-04-30
topic: "Laravel & PHP"
keywords: [laravel octane, outbound requests, connection pooling, http performance, connection reuse, laravel, request optimization, long-lived connections, benchmarking, php performance]
youtube_url: "https://www.youtube.com/watch?v=BWAocgJVCbw"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

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

## Chapters

- Laravel Octane
- Connection Zero Left Intact
- Reuse Connection in Octane
- Measure Connection Reuse vs Not
- When to Use

## Transcript

**Aaron Francis:** Laravel Octane can speed up your app a ton by booting it one time and then serving requests to that booted application. This is not a video about that. I do have that video, but this is a video about a weird little trick that ... O- one weird trick, developers hate them. This is about a weird little trick using Octane that can make your outbound requests, like, five times faster.

**Aaron Francis:** Let me show you what I'm talking about. Here is our application, if you can, if you can even call it that. It is a single route that hits the weather API with my zip code and my private key, which I've already rolled, so don't super care about that. And we don't actually do anything with the response, because I am not actually after the response. What I am after is we're gonna tell Guzzle debug of true.

**Aaron Francis:** So I wanna get a little bit more information from Guzzle about what's happening here. And because this is an Octane application, I'm gonna say Octane start and pass the watch flag, which will gracefully reload this app if we make changes. So this server is running now, and if we hit it in the browser, we see nothing, which is fine. That's what we expected.

**Aaron Francis:** But looking back here in the terminal, we see all kinds of information. So this is all of the information that Guzzle has dumped out here. What I am looking for is the first request comes in, and then it says, "Here's all the Guzzle information." So then it looks up the host, it does a bunch of connections, handshakes, all of this stuff, sends it all off.

**Aaron Francis:** And then the interesting thing, connection zero to the host was left intact. Well, that sure is interesting, isn't it? So I see connection zero left intact, and I think, "Wonder if I could reuse that connection?" In traditional PHP, no. The universe is created, the universe is destroyed every single request.

**Aaron Francis:** In Octane, yes, you can reuse that connection. Is it beneficial? Well, you have to imagine when you're creating a connection, it has to do all the DNS, and then it has to do the, the TLS handshakes. So it's gotta do a lot of stuff to establish a connection. How much stuff? I don't know, but I bet we can find out. So I've got this extremely basic class here. All that it does is creates a new Guzzle client and sets it as a static variable on this class.

**Aaron Francis:** Now, this is super important because using Octane, your app is going to be booted once and then kept in memory, which means any static variables, they're gonna be kept around. So now this client is going to stay alive between requests. So let's take a look over in web, and let's change this.

**Aaron Francis:** Let's just comment this out and say we want client to equal new API client get client. Or what is it? Create client. And then we can actually take this guy, come down here. And so now if we hit this again in the browser, and then we'll hit it again twice.

**Aaron Francis:** Now, come back over here and scroll up. Look at this. Reusing existing connection with weatherapi.com. So this is our second request here, and it says, "I'm just gonna reuse that existing connection." And so it doesn't have to go through that whole negotiation process. So we know already that Guzzle is reusing that connection, but the question still remains: Is it worth it?

**Aaron Francis:** Did we gain anything? Let's measure it and find out. We are gonna use Laravel's benchmark class for that. So we're gonna say benchmark measure, and we're gonna pass a closure through, and we're gonna do this twice. So we're gonna do two different measurements here. One is the plain old Guzzle one. So this is where it will not be reused, and so we gotta pass through use URL there.

**Aaron Francis:** And this one, we will use our static accessor. So we'll use ours that should be preserved there. We don't need all that information anymore, which means this gets a lot simpler, yada, yada, yada. So we will say, um, this is the fresh client, and this is the ...

**Aaron Francis:** What do you wanna call this? The cached client. And so we will, uh, yeah, let's just echo fresh was fresh and cached was cached. And let's see if we can see this in the browser. Okay, so off to a pretty similar start, but then if you look again, now the fresh one is taking 122 milliseconds, and the cached one is taking 28 milliseconds.

**Aaron Francis:** 300 milliseconds versus 27. So you can see that this is a pretty durable result every time we're redoing it. Every time you have to create a fresh client and make that fresh connection, it's taking four to five to six to seven times as long as reusing the existing connection.

**Aaron Francis:** So if your application is making a lot of connections to third parties, you might consider using Laravel Octane and keeping that client as a static variable so that Guzzle will keep that connection open. If you wanna learn more about Laravel Octane, I've got a video that we'll put right here. Until the next time, see ya.

---

## Related on aaronfrancis.com

- [Make 5x faster outbound requests in Laravel](/writing/make-5x-faster-outbound-requests-in-laravel) *(Article · 2024-11-22 · shared: laravel octane, connection reuse, benchmarking)*
- [Laravel Octane: supercharge your Laravel applications](/videos/laravel-octane-supercharge-your-laravel-applications) *(Video · 2024-04-26 · shared: laravel octane, laravel, php performance)*
- [Benchmarking, Type Systems, and Good Hustle](/podcast/benchmarking-type-systems-and-good-hustle-zvir34) *(Podcast · 2023-05-11 · shared: benchmarking, laravel)*
- [About](/about) *(Page · 2026-11-25 · shared: laravel)*
- [Now](/now) *(Page · 2026-11-25 · shared: laravel)*

## Relevant Resources from Aaron Francis

- **[Solo](https://soloterm.com)** (overview on site: [/software](/software)): All-in-one agentic development platform and terminal workspace built by Aaron Francis for orchestrating processes and AI coding agents.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `laravel octane` ([K-L](/llms/keywords/k-l.txt)), `outbound requests` ([O-P](/llms/keywords/o-p.txt)), `connection pooling` ([C](/llms/keywords/c.txt)), `http performance` ([H-J](/llms/keywords/h-j.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
