{"id":548,"date":"2022-03-24T00:12:41","date_gmt":"2022-03-24T00:12:41","guid":{"rendered":"https:\/\/abdelrhmangamal.com\/?p=548"},"modified":"2022-04-11T21:46:20","modified_gmt":"2022-04-11T21:46:20","slug":"what-is-laravel-octane-and-benchmarks%ef%bf%bc","status":"publish","type":"post","link":"https:\/\/abdelrhmangamal.com\/?p=548","title":{"rendered":"What is Laravel Octane? and Benchmarks"},"content":{"rendered":"\n<p>Laravel Octane is the latest offering from the Laravel Team. It boosts our Laravel Application with supersonic speed by utilizing Swoole and RoadRunner. It bootstraps the Laravel framework dependency container, saves it in RAM, and thus cuts the bootstrapping process from each request and provides blazing-fast responses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Octane?<br><\/h2>\n\n\n\n<p>Laravel Octane is a wrapper behind the high-performance servers, Swoole and RoadRunner. Swoole is a PHP extension, which, upon installing, provides us with a myriad of cool and nitty-gritty features such as coroutines, fibers, web-sockets, caching, and so on. On the other hand, RoadRunner is a high-performance application server, load-balancer, and process manager written in GoLang. Octane utilizes one or the other, depending on the developer itself. Nevertheless, it\u2019s worth saying that by using the PHP Swoole extension, Octane gets much more handy features than with RoadRunner.<\/p>\n\n\n\n<p>The idea is that you can get up and running in seconds with Octane if you choose RoadRunner as it\u2019s just a GoLang binary file, and you need to download it, and you\u2019re good to go. As for installing the PHP Swoole extension can become a complex and little cumbersome process, but the end result is way better as it gives you much more features than RoadRunner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How does Octane work?<br><\/h2>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/redberry.international\/wp-content\/uploads\/2021\/12\/download-2-300x128.png\" alt=\"\" width=\"838\" height=\"358\"\/><\/figure>\n\n\n\n<p>The developers love Laravel; even so, there is to raise an issue regarding the performance. We\u2019re not saying that Laravel is slow, but at the very least, it\u2019s not the best beast in the field. Laravel Octane tries to cut that issue in half.<\/p>\n\n\n\n<p>First, let\u2019s understand how Laravel Application is traditionally served under a web server. After a web-server(Apache or Nginx) gets a request, it then delegates the request to PHP-FPM, starting a new worker or reusing the available one.<\/p>\n\n\n\n<p>A worker spawns the new process upon executing a PHP script. After which PHP will include all the files associated with the Laravel Project, and it\u2019s going to read them from the hard disk, and reading from hard disk is always time and resource consuming. Then PHP will bootstrap the Laravel Framework and its dependency container, which most of the time takes much more time and resources than executing business-specific logic.<\/p>\n\n\n\n<p>And finally, our business logic is executed. The idea is that creating new processes, including all those many files from the disk, bootstrapping framework is just time and resource-consuming, and it happens on each and every request. So then, what can Laravel Octane do about it?<\/p>\n\n\n\n<p>Laravel Octane simply caches bootstrapped laravel framework in the RAM on the first request. Every request after it just uses the already bootstrapped framework from the RAM instead of reading the files from the hard disk and re-bootstrapping the framework. And that\u2019s the core idea that boosts the framework performance so much.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Benchmarks.<\/h2>\n\n\n\n<p>\u201c<em>In a post-opcache, post-octane world \u2013 I see no reason to choose Lumen for a new project,<\/em>\u201d \u2013 Says Taylor Otwell, Creator of Laravel.<br>Lumen is a micro-framework based on Laravel, frankly speaking, it\u2019s a Laravel framework without some of the components to make it fast. So Laravel with Octane as its server is way more performance than Lumen. Let\u2019s see some real numbers, shall we?<\/p>\n\n\n\n<p>I decided to stress test the Laravel application in 3 modes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Laravel with Octane<\/li><li>Laravel with Apache WebServer(traditional approach)<\/li><li>Laravel with its Built-In Server<\/li><\/ul>\n\n\n\n<p><br>Well, the results were as you might have imagined. For testing, I used well known, popular tool wrk, with the following configuration:<\/p>\n\n\n\n<p><strong><em>wrk -t1 -c50 &#8216;URL&#8217;<\/em><\/strong><\/p>\n\n\n\n<p>And the testing route was responding with just Hello World HTML, nothing fancy, but even with that, the result is quite interesting.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"294\" src=\"https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image.png\" alt=\"\" class=\"wp-image-551\" srcset=\"https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image.png 823w, https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image-300x107.png 300w, https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image-768x274.png 768w, https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image-256x91.png 256w, https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image-800x286.png 800w\" sizes=\"auto, (max-width: 823px) 100vw, 823px\" \/><\/figure>\n\n\n\n<p>Source<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel Octane is the latest offering from the Laravel Team. It boosts our Laravel Application with supersonic speed by utilizing Swoole and RoadRunner.<\/p>\n","protected":false},"author":1,"featured_media":551,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[40],"tags":[],"class_list":["post-548","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel-framework"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.11 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Laravel Octane? and Benchmarks - Abdelrhman Gamal<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Laravel Octane? and Benchmarks - Abdelrhman Gamal\" \/>\n<meta property=\"og:description\" content=\"Laravel Octane is the latest offering from the Laravel Team. It boosts our Laravel Application with supersonic speed by utilizing Swoole and RoadRunner.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abdelrhmangamal.com\/?p=548\" \/>\n<meta property=\"og:site_name\" content=\"Abdelrhman Gamal\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-24T00:12:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-11T21:46:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"823\" \/>\n\t<meta property=\"og:image:height\" content=\"294\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abdelrhmangamal.com\/?p=548\",\"url\":\"https:\/\/abdelrhmangamal.com\/?p=548\",\"name\":\"What is Laravel Octane? and Benchmarks - Abdelrhman Gamal\",\"isPartOf\":{\"@id\":\"https:\/\/abdelrhmangamal.com\/#website\"},\"datePublished\":\"2022-03-24T00:12:41+00:00\",\"dateModified\":\"2022-04-11T21:46:20+00:00\",\"author\":{\"@id\":\"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/37df82e7a8c0027f621c916f9044f978\"},\"breadcrumb\":{\"@id\":\"https:\/\/abdelrhmangamal.com\/?p=548#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abdelrhmangamal.com\/?p=548\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abdelrhmangamal.com\/?p=548#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/abdelrhmangamal.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is Laravel Octane? and Benchmarks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/abdelrhmangamal.com\/#website\",\"url\":\"https:\/\/abdelrhmangamal.com\/\",\"name\":\"Abdelrhman Gamal\",\"description\":\"Software Engineer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/abdelrhmangamal.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/37df82e7a8c0027f621c916f9044f978\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6368eb07883bf34cac0667420f263bcd8168e9cddf28fe0a276ff04700127482?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6368eb07883bf34cac0667420f263bcd8168e9cddf28fe0a276ff04700127482?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/abdelrhmangamal.com\"],\"url\":\"https:\/\/abdelrhmangamal.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Laravel Octane? and Benchmarks - Abdelrhman Gamal","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"What is Laravel Octane? and Benchmarks - Abdelrhman Gamal","og_description":"Laravel Octane is the latest offering from the Laravel Team. It boosts our Laravel Application with supersonic speed by utilizing Swoole and RoadRunner.","og_url":"https:\/\/abdelrhmangamal.com\/?p=548","og_site_name":"Abdelrhman Gamal","article_published_time":"2022-03-24T00:12:41+00:00","article_modified_time":"2022-04-11T21:46:20+00:00","og_image":[{"width":823,"height":294,"url":"https:\/\/abdelrhmangamal.com\/wp-content\/uploads\/2022\/03\/image.png","type":"image\/png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/abdelrhmangamal.com\/?p=548","url":"https:\/\/abdelrhmangamal.com\/?p=548","name":"What is Laravel Octane? and Benchmarks - Abdelrhman Gamal","isPartOf":{"@id":"https:\/\/abdelrhmangamal.com\/#website"},"datePublished":"2022-03-24T00:12:41+00:00","dateModified":"2022-04-11T21:46:20+00:00","author":{"@id":"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/37df82e7a8c0027f621c916f9044f978"},"breadcrumb":{"@id":"https:\/\/abdelrhmangamal.com\/?p=548#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/abdelrhmangamal.com\/?p=548"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/abdelrhmangamal.com\/?p=548#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/abdelrhmangamal.com\/"},{"@type":"ListItem","position":2,"name":"What is Laravel Octane? and Benchmarks"}]},{"@type":"WebSite","@id":"https:\/\/abdelrhmangamal.com\/#website","url":"https:\/\/abdelrhmangamal.com\/","name":"Abdelrhman Gamal","description":"Software Engineer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/abdelrhmangamal.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/37df82e7a8c0027f621c916f9044f978","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/abdelrhmangamal.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6368eb07883bf34cac0667420f263bcd8168e9cddf28fe0a276ff04700127482?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6368eb07883bf34cac0667420f263bcd8168e9cddf28fe0a276ff04700127482?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/abdelrhmangamal.com"],"url":"https:\/\/abdelrhmangamal.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=548"}],"version-history":[{"count":1,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions\/615"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=\/wp\/v2\/media\/551"}],"wp:attachment":[{"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abdelrhmangamal.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}