Advanced Search

Results 1 to 9 of 9

Thread: Things consider to reduce server untlization in php

  1. #1
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default Things consider to reduce server untlization in php

    What are the things a programmer/developer should consider when writing php codes to reduce the usage server resources ,

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    This is a very broad question and is difficult to answer. Please ask a more specific question.

    There are many things you can do, and some things you should not do. But it depends on what you're trying to accomplish. Also, please describe your site a bit-- are you getting thousands of visitors every day? Or are you worried about the server load for just a few visitors? A site like facebook has very different concerns than a small site due to the amount of traffic-- even a tiny difference in server load is huge when multiplied out for all of the users, but it wouldn't matter on most sites.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default

    @Dany..

    Thanks fr your message.
    Yes , I think, may be I should worry about the problem of traffic in near future. If the website have not that much of traffic, why can't we apply the logic for reducing the server resources in every application.

    I think using javascript do some more things to reduce the usage of server resources. I am not looking for a detailed explanation, but for important points we need to consider when we build a huge traffic website

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,881
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    I am not looking for a detailed explanation, but for important points we need to consider when we build a huge traffic website
    Just a quick rundown of things that can make a website "lighter" and faster and therefor reduce server load. Not coding related as such, but things to bear in mind all the same.

    1. Use the right image format.
    2. Optimise images.
    3. Use image sprites to reduce HTTP requests.
    4. Substitute images for Data URIs to reduce HTTP requests - adding the image data to a CSS file instead has the benefit of making them cacheable.
    5. Optimise/minify HTML, CSS and JavaScript to make the pages/files smaller - includes removing extra markup/whitespace, moving styling/presentation to external CSS to make it cacheable, and using CSS shorthand so keep it streamlined.
    6. Combine multiple external CSS and JavaScript files to reduce HTTP requests.
    7. Serve CSS and images from another domain/host to spread server load and make use of parallel downloading.
    8. Enable gzip - htaccess or via php - you can then convert external JavaScript and CSS to php and enable gzipping inside them.
    9. Set far future headers on cacheable files such as CSS, JavaScript and images.
    10. Link to publicly hosted JavaScript libraries such as jQuery on Google API.
    11. Disable hot linking on images/media files in case other websites are likely to link directly to them.
    12. Host resources on external sites instead of your own - eg. YouTube for videos.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  5. #5
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default

    @Bever
    Thanks for your message.
    Which is the best following method ?
    Suppose i have 4 style sheets and i combined coding of these 4 css into a 1 and calling this single big css in HTML page OR calling one style sheet in HTML page and importing remaining 3 into that 1... which is the best idea to reduce the HTTP requests.

  6. #6
    Join Date
    Jul 2012
    Posts
    197
    Thanks
    55
    Thanked 3 Times in 3 Posts

    Default

    Link to publicly hosted JavaScript libraries such as jQuery on Google API.
    Can we trust these third parties, that they will not change the link of these publicly hosted js libs. If tmrw they are going to change the link without informing the outside world , the people who follow these links may get trapped with bad issues in the website ? eh ?

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Quote Originally Posted by letom View Post
    Can we trust these third parties, that they will not change the link of these publicly hosted js libs. If tmrw they are going to change the link without informing the outside world , the people who follow these links may get trapped with bad issues in the website ? eh ?
    Theoretically, they could change the content at any time, and in general:
    1) Don't assume third-party websites will never change. They might change!
    2) Don't use resources from third-party websites without permission.

    But... third-party websites specifically designed for this (jQuery and Google API are good examples) will not change because they're intentionally designed to stay the same. Of course they may release an update, but that would have a new URL.


    A while ago, Google offered "Google Translate API", and then they thought it was being abused so they decided to discontinue the service (note that this is a service, in addition to a script, so it likely wouldn't be a problem for a script only). But when that happened, they gave, I believe, 12 months notice to all webmasters so that they could update their sites in time.

    In short: yes, you can trust these websites because they are designed to be used for this purpose. But check the TOS and other information on a different website to find out if it's the same before hotlinking there.
    Last edited by djr33; 03-26-2013 at 10:12 PM.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. The Following User Says Thank You to djr33 For This Useful Post:

    letom (03-27-2013)

  9. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,881
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    Quote Originally Posted by letom View Post
    @Bever
    Thanks for your message.
    Which is the best following method ?
    Suppose i have 4 style sheets and i combined coding of these 4 css into a 1 and calling this single big css in HTML page OR calling one style sheet in HTML page and importing remaining 3 into that 1... which is the best idea to reduce the HTTP requests.
    Assuming that all 4 stylesheets are being used on the majority of pages, it would be better to combine them in to 1 file rather than use @import, which has negative effects on performance. Of course you'd need to assess each website on a case-by-case basis - if you have a reasonably large CSS file that is only used in one page (eg, a gallery) then it would be better to link to that as well as the default site stylesheet, in the page that needed it, rather than impose it on the rest of your site in one massive combined file.

    If you wanted to keep component CSS broken down as separate files, an alternative to @import would be to convert the CSS file to php http://css-tricks.com/css-variables-with-php/ and then use php's include() instead. At the same time you can compress http://css-tricks.com/snippets/css/c...-css-with-php/ and enable gzip in the file too with ob_start("ob_gzhandler"); http://php.net/manual/en/function.ob-gzhandler.php
    Last edited by Beverleyh; 03-26-2013 at 09:29 PM.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  10. The Following User Says Thank You to Beverleyh For This Useful Post:

    letom (03-27-2013)

  11. #9
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,881
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    I stumbled on an interesting IE 'quirk' this morning and given the recent talk of combining CSS files, I thought that it was appropriate to add to this thread.

    IE keels over at 4096 selectors in CSS. http://www.thecssdiv.co.uk/2009/08/a...weird-ie6-bug/
    A case where combining multiple stylesheets into one *could* cause problems.

    So if you have a hugely massive CSS file and notice that IE isn't applying the styles towards the bottom, its actually a good idea to split it into multiple stylesheets
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

Similar Threads

  1. reduce redundency
    By spyder in forum JavaScript
    Replies: 1
    Last Post: 07-10-2009, 08:50 AM
  2. reduce redundency
    By spyder in forum HTML
    Replies: 2
    Last Post: 07-08-2009, 10:02 PM
  3. loop help to reduce redundant code
    By jasrasr in forum JavaScript
    Replies: 1
    Last Post: 06-22-2009, 03:26 PM
  4. Reduce content of iframe
    By stefaneh in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 02-27-2007, 09:06 PM
  5. How to reduce H1 tags to a normal size
    By John_fresh in forum HTML
    Replies: 1
    Last Post: 01-17-2007, 02:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •