Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 573433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:43:24+00:00 2026-05-13T13:43:24+00:00

I’m building a webapp using php, ajax, javascript, mysql. I’ve been worring about something

  • 0

I’m building a webapp using php, ajax, javascript, mysql. I’ve been worring about something for a while, but not sure if it’s really a problem or not. Here’s the basic concept of how the code is working…I would like to know if I should change it now, or if it is o.k to use as is. Performance is important to me…over 5,000 users should be able to use the app without much of a performance problem. Part of my worrying is just paranoia of being self taught developer and not knowing all the best practices out there.

Here’s the basic webapp functionality:

user executes a call via the browser through onclick event –> ajax call to phpPG1.php. –> phpPG1.php runs a query against the db and stores the results in array, then includes another php page called HTMLphp.php, instantiates new object from HTMLphp.php page, which is a class –> calles function of the class and passes the array that contains the results of a query–>the class functions builds the HTML table and passes back a string –> the phpPG1.php page sends back the string with the table data to the ajax call which displays the string in the given DIV tag it belongs in.

The HTMLphp.php contains all the functions that are used to return HTML tables for the whole webapp. HTMLphp.php would look something like this:

Class HTML_stuff
{
   function html_TABLE1($results_array)
   {

      $string = 'THE HTML TABLE WITH ITS DATA IN IT'
      return $string
   }

   function html_TABLE2($results_array)
   {

      $string = 'THE HTML TABLE WITH ITS DATA IN IT'
      return $string
   }

}

So, here’s my question. the HTMLphp.php page has 5,606 lines of code in it right now, which represents 100 or so functions in the class. Basically, every page in my webapp “includes” this page into it in order to be able to use the class functions to display the html tables. I’m about half way done with the webapp, so there will be a lot more lines of code do add to this file. I’m not exactly up to par on how computers execute code, especially when using class objects, but I understand the basics if “interpretive languages” like php.

I’m wondering if this is a bad idea and if I should do something like this: For each function inside the HTML_stuff class just simply remove the code for each function and place it in it’s own separate .php page that gets included like this:

Class HTML_stuff
{
   function html_TABLE1($results_array)
   {
      include_once 'TABLE1.php'; //the html table for this function.
      return $string;
   }

   function html_TABLE2($results_array)
   {
      include_once 'TABLE2.php';
      return $string;
   }
}

My basic assumption is that I only include the HTML needed when I make the call to the particular function, thus reducing the overall size of the HTMLphp.php page assuming this would help in overall site performance…am i in left field with this thinking? Part of me is thinking that this is simply the same as the first option, just organized differently and it would do anything to the overall performance. However, I did read somewhere that fewer “includes” is better for performance.

What do other people do, or are there other best practices on how to do this sort of thing? Is it negligible to worry about this with a site of say 5,000 – 10,000 users?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:43:24+00:00Added an answer on May 13, 2026 at 1:43 pm

    Including the specific PHP file inside a function/method rather than an open include will definitely help things as only the needed items will get included and interpreted. But the PHP intrepreter will still need to go through those 5000 lines code of that huge class, which IMHO is a really bad way to go about it, and will be a major bottleneck.

    In reality, 5000-10000 users is not a whole lot, but it again depends on how the usage is going to be. If all of them could be logged in simultaneously, and shooting out requests at your server (something like 10k requests per minute or 166 req/s approx.) and there’s little or no caching involved, then it could be a serious bottleneck but that again depends on a lot of factors. Instead, a good way to go about it would be to use some sort of load testing tool like ab or JMeter and find it out for real.

    If the results don’t look so good after doing these tests, then find out what the bottleneck is. You could use APC or Memcache to implement caching, or various other ways to improve performance. But taking a wild shot in the dark, I’d say that 5k line class is something that you should consider splitting, not just for performance reasons but also for a good design. And perhaps, if the logic of building those HTML pieces is not too complex, you could offload that to the client by sending the data as JSON/XML, and letting Javascript construct the table using this data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 379k
  • Answers 379k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are searching for ;SERVER_NAME|s:" which clearly is not present… May 14, 2026 at 9:42 pm
  • Editorial Team
    Editorial Team added an answer If your consumer of the content provider is in the… May 14, 2026 at 9:42 pm
  • Editorial Team
    Editorial Team added an answer 1) Add all user controls inside a parent page with… May 14, 2026 at 9:42 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.