Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

List of Performance Checklist for LAMPP ?

1. Use Apache mod_expires caching

Apache mod_expires caching is a way to improve the performance of your website by caching static content. Static content is content that does not change frequently, such as images, CSS files, and JavaScript files.

When a user visits your website, their browser will first check to see if it has a cached copy of the static content. If the browser has a cached copy of the content, it will display the cached copy instead of downloading the content from the server. This can save a lot of time and bandwidth, especially for users who are visiting your website for the first time.

Example :-

  1. Enable the mod_expires module in Apache. You can do this by adding the following line to your Apache configuration file:
LoadModule expires_module modules/mod_expires.so

Here is an example of an Apache configuration file that uses mod_expires caching:

<VirtualHost *:80>
    ServerName example.com

    LoadModule expires_module modules/mod_expires.so

    ExpiresByType image/png "access plus 1 hour"
    ExpiresByType image/gif "access plus 1 hour"
    ExpiresByType image/jpeg "access plus 1 hour"
    ExpiresByType text/javascript "access plus 1 week"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/html "access plus 1 day"

    DocumentRoot /var/www/example.com/public
</VirtualHost>

2. Use opcode cache

What is opcode cache?

Opcode cache is a mechanism used to improve the performance of PHP applications by storing the compiled opcode of PHP scripts in memory. This means that the PHP interpreter does not have to parse and compile the scripts every time they are requested, which can significantly improve the load time of PHP applications.

How to use opcode cache in LAMPP ?

To use opcode cache in LAMPP, you need to first enable the PHP OPcache extension. This can be done by adding the following line to the php.ini file:

Got to below path and uncommend below code

/opt/lampp/etc
zend_extension=opcache.so

Once the extension is enabled, you need to restart the LAMPP server. You can do this by running the following command:

sudo /opt/lampp/lampp restart

3. Optimize your database queries

Database queries can have a significant impact on the performance of web applications. It is important to optimize your database queries to reduce the time it takes to retrieve data from the database.

Here is an example of an unoptimized database query:

SELECT id, username FROM users WHERE username = 'Amit Kumar' LIMIT 1;

This query will return all of the rows in the users table where the username column is equal to johndoe. However, this is not very efficient, because it is likely that you only need to return a single row.

4. Enable Firewall

What is Firewall and Allow Necessary Ports ?

Enabling a firewall and allowing necessary ports are security measures to control and regulate network traffic to and from your computer or server. Firewalls act as a barrier between your system and the internet or other networks, helping to prevent unauthorized access and securing your system.

Why We need to do this Firewall Ports ?

Enabling a firewall and managing open ports is a crucial aspect of securing your computer or server. Here’s why managing firewall ports is important:

  1. Security:
    • Unauthorized Access Prevention: Firewalls help prevent unauthorized access to your system by blocking incoming connections that are not explicitly allowed.
    • Network Segmentation: By controlling which ports are open, you can segment your network and limit exposure to potential security threats.
  2. Protection Against Exploits:
    • Exploit Prevention: Firewalls protect your system from potential exploits and attacks by controlling which services and ports are accessible.
  3. Controlled Access to Services:
    • Service Restriction: You can control which services are accessible from the network. For example, you may allow access to web services (HTTP and HTTPS) but restrict access to certain administrative services.

Security thread if i ignore this Firewall and Allow Necessary Ports ?

If you ignore your firewall and allow necessary ports, you could be putting your system at risk of a number of security threats, including:

  • Malware attacks: Malware can exploit open ports to gain access to your system and steal your data, install malware, or launch denial-of-service (DoS) attacks.
  • Unauthorized access: Attackers can use open ports to gain unauthorized access to your system and steal your data, or launch attacks against other systems on the network.
  • DoS attacks: DoS attacks can overwhelm your system with traffic, making it unavailable to legitimate users.
  • Man-in-the-middle attacks: Man-in-the-middle attacks allow attackers to intercept and modify communication between your system and other systems on the network.

Example :-

sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

5. Adjust PHP Settings

Increase memory_limit based on your requirements

Go to php.ini and put as below code

memory_limit = 512

Here are some other PHP settings that you may want to optimize for performance:

  1. max_execution_time: This setting specifies the maximum amount of time that PHP scripts can execute before they are terminated. It is recommended to increase this value from the default of 30 seconds to at least 60 seconds, or higher if your application requires more time to execute.
  2. post_max_size: This setting specifies the maximum size of POST requests that PHP will accept. It is recommended to increase this value from the default of 8M to at least 16M, or higher if your application is submitting large POST requests.
  3. upload_max_filesize: This setting specifies the maximum size of uploaded files that PHP will accept. It is recommended to increase this value from the default of 2M to at least 4M, or higher if your application allows users to upload large files.

6. Optimize JavaScript and CSS

Minimize and concatenate JavaScript and CSS files to reduce the number of HTTP requests and improve page loading times.
There are a number of ways to optimize JavaScript and CSS to improve the performance of web pages:

JavaScript

  1. Minify JavaScript code. Minification removes unnecessary whitespace, comments, and other characters from JavaScript code, without affecting the functionality of the code. This can significantly reduce the size of JavaScript files, which can improve the load time of web pages.
  2. Use a JavaScript bundler. A JavaScript bundler can bundle multiple JavaScript files into a single file, which can improve the performance of web pages by reducing the number of HTTP requests that need to be made.
  3. Load JavaScript asynchronously. Asynchronous loading allows JavaScript files to be loaded in the background, without blocking the rendering of the web page. This can improve the perceived performance of web pages, especially on mobile devices.
  4. Use a JavaScript library. There are a number of JavaScript libraries available that can provide common functionality, such as DOM manipulation and animation. Using a JavaScript library can improve the performance of web pages by reducing the amount of code that needs to be written and maintained.

7. Optimize Session Handling

Session handling is the process of tracking and managing user sessions on a website. A session is a period of time during which a user is actively interacting with a website. Session handling is important because it allows websites to provide personalized experiences to users, such as remembering their login status and shopping cart items.

There are a number of ways to optimize session handling, including:

  1. Use a database to store session data. This is the most common and reliable way to store session data. It is also the most scalable way to store session data, as it can handle a large number of concurrent users.
  2. Use a caching mechanism to store session data in memory. This can improve the performance of your website by reducing the number of database queries that need to be made. However, it is important to note that caching session data in memory can be less reliable, as the data can be lost if the server crashes or restarts.
  3. Use a session timeout. A session timeout is a period of time after which a user’s session will be automatically terminated. This can help to improve security and reduce the load on your server.

Example :-

return [

    'session' => [

        // Use the database to store session data
        'driver' => 'database',

        // Use the Memcached cache driver to store session data in memory
        'cache_driver' => 'memcached',

        // Set the session timeout to 2 hours
        'lifetime' => 120,

    ],

];

8. Enable GZIP compression in .htaccess

If you have setup Apache Virtual Host, you can open the .htaccess file for your website and add the following lines in it. Else you can create a blank .htaccess file under main document root (/var/www/html)

sudo vim /var/www/html/.htaccess

Add the following lines to it

# GZIP compression for text files: HTML, CSS, JS, Text, XML, fonts
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
</IfModule>

What are the Benefits of using Enable Compression

  1. Reduced bandwidth usage: GZIP compression can reduce the size of HTTP responses by up to 90%, which can significantly reduce bandwidth usage. This can be especially beneficial for websites with a lot of text-based content, such as blogs and news websites.
  2. Improved performance: By reducing the size of HTTP responses, GZIP compression can also improve the performance of your website by reducing the time it takes for pages to load. This is because the browser will be able to download the smaller responses more quickly.

We use AddOutputFilterByType directive to tell Apache as to which file types to compress.

Next restart the apache server

sudo /opt/lampp/lampp restart

9. Config Caching

Config caching in Laravel is a way to improve the performance of your application by caching the configuration files. By caching the configuration files, Laravel can avoid having to load them from disk every time they are needed. This can significantly improve the performance of your application, especially if you are using a large number of configuration files.

Example :-

php artisan config:cache
php artisan config:clear

10. Optimise Mysql

Optimizing the database is a very effective performance boost that many of us overlook! You’ll want to analyse the database queries running on your server, and tweak the MySQL performance to match the server needs.

Database performance depends on several factors at the database level, such as tables, queries, and configuration settings. These software constructs result in CPU and I/O operations at the hardware level, which you must minimize and make as efficient as possible.

There are a number of ways to optimize MySQL for performance, including:

  1. Use the right storage engine. MySQL supports a number of different storage engines, each with its own strengths and weaknesses. For most applications, the InnoDB storage engine is the best choice. InnoDB is a transactional storage engine that provides high performance and reliability.
  2. Index your tables. Indexes allow MySQL to quickly find the data that it needs. For tables that are frequently queried, it is important to create indexes on the columns that are used in the queries.
  3. Normalize your database. Database normalization involves organizing your data into a set of tables in a way that reduces redundancy and improves data integrity. Normalizing your database can improve performance by reducing the amount of data that MySQL needs to access.
  4. Use a caching mechanism. A caching mechanism can store frequently accessed data in memory, which can improve performance by reducing the number of times that MySQL needs to access the database.
  5. Tune your MySQL configuration. There are a number of MySQL configuration parameters that can be tuned to improve performance. However, it is important to be careful when tuning MySQL configuration parameters, as incorrect changes can lead to performance problems or data corruption.

Example :-

Create indexes on the columns that are used in frequently executed queries. To create an index on a column, you can use the following SQL statement:

CREATE INDEX index_name ON table_name (column_name);
Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x