PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, May 21, 2022

Determine server requirements for a PHP, MySQL application

 May 21, 2022     mysql, php, programming     No comments   

 


Determine your peak load number of concurrent users.

The first thing you'll need to do is figure out what the peak load of your application is. Your application's peak load is the most amount of people you expect to be using your application at any given time. For example, if you're making a large social network and you think that at some point all 3 billion users will go online at once, then your peak load number would be 3 billion.

To determine your peak load number:

  • First you'll want to take a look at how many total users you think will use your product in a day (for example 10,000).

  • Now figure out how many times those users are going to hit the server for content in a day (for example 1,000 times per user per day), and multiply that by the number of days in that month (for example 30) = 30,000 server hits per day.

  • Next take that daily hit number (30,000) and divide it by 24 hours = 1250 hits per hour.

  • Then divide that hourly hit number by 60 minutes = 20.8 hits per minute.

  • Finally divide that minute hit number by 60 seconds = 0.35 hits every second or a little less than one hit per second during peak time each day. A good rule of thumb here is to upsize this amount 50% so we'll just say one server request every second during peak time each day will be enough for this hypothetical example app

Determine the load time for a user request to be served.

Take the time to create a profile of your application. This includes determining factors such as:

  • How long does it take for a single query to run?

  • How long does it take for the server to generate the response?

  • How long does it take for your page/site to load on average? (This can be done fairly easily with an online tool like [WebPageTest](https://www.webpagetest.org).)

  • How many queries are run per page request, and how often do they happen? (Queries that happen rarely should be less of a concern than ones that are a part of every single request.)

  • If you have users who can log in, how many pages do they visit per hour, per day? What about casual visitors who don't log in, but simply browse your site or app?

If you have any analytics from existing projects or sites you've worked on, this is the perfect time to bring them out and use them as part of your calculations. Start by making some very basic estimates based on what you know about your application's code, then gather some more defined numbers using comprehensive testing tools like JMeter or LoadStorm.

Calculate the CPU usage on the server required to fulfill the user requests.

Once you've used a load testing tool to measure the load time of a user request, calculate the CPU usage on the server required to fulfill all user requests by multiplying the peak number of concurrent users by the load time for each user request. In this example, we have a peak number of concurrent users of 500 and a load time per user request of .07 seconds.

By multiplying these values we can easily determine that 35 CPU seconds are required to serve each peak second.

Calculate the RAM usage on the server required to fulfill the user requests.

You need to determine the amount of RAM required on the server to fulfill all the user requests. To do this, you'll need to first determine the number of requests per second (RPS) and then calculate the amount of memory required for each request.

From this, you can multiply out the memory used by a single request to find the total amount required by your application.

To calculate RPS, use one of these two methods:

  • Determine RPS using ApacheBenchmark: apachebench is a benchmarking tool designed specifically for web servers and it allows you to test how many requests a web server can handle in a set period of time. This is a good option if you don't have historical data about your application's usage patterns or want to see how well your new machine performs compared against previous ones. To set up apachebench (ab), follow these steps:

  • Install ab on your machine using apt-get or yum

  • Use ab -k -c 100 -n 10000 http://www.yourwebsite.com to load test your app with 100 concurrent users over 10 seconds

  • RPS = Total Requests / Test Time = Total Requests / 10 seconds (in this case)

  • Calculate RPS based on historical data about number of daily visitors and average time spent on website: Take an average day in which you had x daily visitors and where each visitor was on average there for y minutes . If each minute has 60 seconds, then we have x*y*60 = z total seconds that our site was accessed per day . So z/24 hours = rps since there are 24 hours in a day

Calculate the total storage capacity (CPU and RAM) on the server required to handle your peak number of users.

In order to do this, you will need to know:

  • The total storage capacity (CPU and RAM) required for the application on a per-user basis.

  • The maximum number of concurrent users that will access your application at any given time.

The sum of all these calculations is the total storage capacity that is required on your server to handle all of your user requests simultaneously.

It is important to know how much hardware you will need to support your application so there aren't any surprises when your application is live.

 By following above steps, you should be able to determine hardware requirements for your PHP Application. If you are using a Cloud platform, you can buy a server instance with required RAM, CPU and Bandwidth 

  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,258,894

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing