TeddyKiller Posted July 4, 2010 Share Posted July 4, 2010 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? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted July 4, 2010 Share Posted July 4, 2010 They have a lot of dedicated web servers, a lot of dedicated database servers, and a lot of dedicated bandwidth. Do you have any of those things? Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 4, 2010 Author Share Posted July 4, 2010 My bandwidth is unlimited but im on a shared host, i know Unlimited isn't actually unlimited, its like.. unmetered or something. Though what do you mean by alot of database servers, and web servers? Quote Link to comment Share on other sites More sharing options...
Alex Posted July 4, 2010 Share Posted July 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 4, 2010 Author Share Posted July 4, 2010 ooo .. can you explain more about that please? Also, what do you both mean about having loads of web servers, and database servers? How can you make a website run on multiple web servers? o.O Quote Link to comment Share on other sites More sharing options...
GetFreaky Posted July 5, 2010 Share Posted July 5, 2010 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. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 5, 2010 Author Share Posted July 5, 2010 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? Quote Link to comment Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 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... Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 5, 2010 Author Share Posted July 5, 2010 What do you mean by database indexes? What advice can you give to make code 'un'sloppy, apart from what AlexWD gave? Quote Link to comment Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 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 Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 5, 2010 Author Share Posted July 5, 2010 I'm looking at xDebug now, but the download file is a .dll, what do I do with it? Quote Link to comment Share on other sites More sharing options...
travo1992 Posted July 5, 2010 Share Posted July 5, 2010 Installation instructions are in the documentation. Its a PHP extension (you need to be running a local server). I forgot to mention before, but you should also look at http://code.google.com/p/webgrind/ if you go ahead with xdebug. I believe its te better of the grind viewers Quote Link to comment Share on other sites More sharing options...
dreamwest Posted July 5, 2010 Share Posted July 5, 2010 Take a look at this: http://www.wizecho.com/nav=tricks&s=speed Then get smarty 3 and set caching to true, then {nocache}{/nocache} tags where dynamic content is....check out gamefaqs website to see smarty 3 in action Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted July 5, 2010 Author Share Posted July 5, 2010 So after doing that, I'd need to change my code to suit {nochache} tags? o.O Quote Link to comment Share on other sites More sharing options...
dreamwest Posted July 5, 2010 Share Posted July 5, 2010 No, {nocache} in your tpl files will stops smarty from caching that section of code. Your php files stay the same Smarty is god!, do a test with it, and join us on the light side of the force Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.