Jump to content

How to make your webpage load faster?


TeddyKiller

Recommended Posts

I believe its common knowledge that.. the more code you have, the slower your page loads.

 

Though with sites like SMF, Facebook other HUGE sites.. how do they load so quick when they have aload of code?

 

My site sometimes runs slow and I want to know how to speed it up.

 

I'm not too sure if this is the right place, but it is the PHP i'm talking about, I have a massive config file.. consisting of a settings file, session and user file, language file, database file, mailer file, side bar file (but im removing that) and image file (again, removing it as It's going ot be included into pages that need it).

 

This slows down website performance, as it really does take its time to load... apart form the two files with the brackets next to, all files included are needed for every page made so far.

 

Now, maybe that config file, is tiny compare to some sites, but how could I make the performance of my code load faster?

Link to comment
Share on other sites

You need to test your code to find which part of it is slowing down your website. Then you can figure out how to optimize it. It's not about size as much as efficiently. You can have 10 inefficient lines of code that take longer to execute than 10,000 lines of efficient code.

 

The reason that large websites like facebook need so many servers to operate is because of the sheer size of their user-base.

Link to comment
Share on other sites

I believe the main reason as mentioned by most users is that they do infact have their own dedicated servers. You have other servers which run hundreds and thousands of websites, but then you have 1 giant server for  1 website, you can imagine the speed and runtime of the website would be extremely fast.

Link to comment
Share on other sites

Most sites infact dont need to use server clustering if you have a decent dedicated server... but facebook once started off slow, and made shed loads of money through ads, so they could upgrade. I'm going up to a VPS to remove my inode limit and process limit.

 

At the moment I'm limitting my site to 1000 users... just to be safe of that.

 

Need to perhaps revise some of my code to see if i can speed it up even the slightest. The money that 1000 users can bring if setup correctly is quite good, just hope luck comes my way. By the time I need to server cluster, it'd be a major upgrade and a downfall of 1 weeks uptime maybe, but i should earn enough money to be able to do that and be happily with the changes...

 

Hmmm.. I use alot of includes, because I have alot of classes... but theres not really a way I can reduce that is there apart from just get rid of it all?

Link to comment
Share on other sites

You should be doing better than fine with 1000 users. I know of a few sites with 20,000-30,000 users which are still running sub 0.5 seconds on shared hosting, you just need to make sure your code is not sloppy, your database indexes are correct, etc.

 

EDIT: Did you mean total users or users at once? Apache defaults to a maximum of 256 connections at once, so you dont really need to worry about much if this is what you meant...

Link to comment
Share on other sites

Database indexes - practises such as primary keys on ids, indexing columns that will be referenced, full text searching, etc. (Take that statement loosely, I know that doing tha as I said it may result in slower data access)

 

As for code, really just use your head and remember that there are always the right and wrong tools for the job.

Eg.

If there is a function built into PHP, 9 times out of 10 it will be quicker than your PHP function which does the same job.

 

If you wish to profile your scripts and see where you are losing time, have a look at Xdebug

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.