Book Image

High Performance with Laravel Octane

By : Roberto Butti
5 (2)
Book Image

High Performance with Laravel Octane

5 (2)
By: Roberto Butti

Overview of this book

Laravel Octane is a very powerful component in the Laravel ecosystem that can help you achieve remarkable app performance. With Laravel Octane, you will find tools (queues, cache, and tables) that facilitate a new asynchronous approach for improving application performance. This book highlights how Laravel Octane works, what steps to take in designing an application from the start, what tools you have at your disposal, and how to set up production environments. It provides complete coverage of the strategies, tools, and best practices to make your apps scalable and performant. This is especially important as optimization is usually the overlooked part in the application development lifecycle. You will explore the asynchronous approach in Laravel and be able to release high-performing applications that have a positive impact on the end-user experience. By the end of this book, you will find yourself designing, developing, and releasing high-performance applications.
Table of Contents (14 chapters)
1
Part 1: The Architecture
3
Part 2: The Application Server
6
Part 3: Laravel Octane – a Complete Tour
9
Part 4: Speeding Up

Understanding the Laravel Web Application Architecture

This book is for Laravel developers who would like to make or design their Laravel web application in a more scalable way and make it more performant.

This book aims to provide you with knowledge, suggestions, and explanations on how to improve the software architecture of a web application, starting from a typical PHP web application architecture to a more scalable and performant architecture.

It provides a 360-degree overview of what it takes to design and build a performant application with Laravel Octane. We’ll see why Laravel Octane is suitable for designing and building a performant application. The book also covers the different tools used by Laravel Octane, such as Open Swoole and RoadRunner, and lists and describes the various features and differentiating elements. But the most important thing is to enable you to understand why and when to use Open Swoole or RoadRunner.

But before starting, why use Laravel Octane?

Laravel Octane is a tool that allows us to access some functionality and features exposed by the two application servers we just mentioned.

One of the benefits of Laravel Octane is the huge improvement in the response times to HTTP requests by clients such as web browsers. When we develop a Laravel application, we use an important software layer implemented by the framework. This software layer needs time and resources to start. Even if we talk about only a few resources and a short amount of time, this repeated action for each request, especially in a context where there are many requests, can be a problem. Or rather, its optimization could bring enormous benefits.

Laravel Octane, through application servers, does just that: optimizes the process of starting the framework, which typically happens for each individual request. We will see in detail how this is done; essentially, the objects and everything that the framework needs are started and allocated to the start of the application server, and then the instances are made available to the various workers. Workers are the processes that are initiated to serve the requests.

Another reason why it is interesting to evaluate the adoption of Laravel Octane in your Laravel web application is that by using an application server such as Swoole, you can access those features implemented by Swoole.

The functions are, for example, the advanced mechanisms of the cache driver, shared storage for sharing information between the various workers, and the execution of tasks in parallel.

This is a totally new concept to the classic PHP developer who typically does not have an immediate functionality available in the PHP core for the parallelization of processes.

This chapter will introduce you to the Laravel ecosystem and explore what Laravel Octane is.

This chapter aims to introduce you to the application server approach, in which more workers cooperate to manage multiple requests. Understanding the behavior under the hood allows the developer to avoid some mistakes, especially on shared resources (objects and global states) across the worker. This is important because the classical PHP approach is to have one dedicated thread to manage one request.

In this chapter, we will cover the following topics:

  • Exploring the Laravel ecosystem
  • Understanding the request lifecycle
  • Getting to know the application server