Im getting slow database requests - need help

Discussion in 'Site & Server Administration' started by articledirectory, Jan 8, 2008.

  1. #1
    I have had a bog standard, unmanaged p4, dedicated server for some time now, Ive never done anything to it. other than a monthly reboot to keep things in order. I have about 20-30 sites running on it. most are database driven and all of them work very well except a new site that's starting to be developed on it. its a celebrity photos site at the lag between page loads it awful, it loads the homepage fine but if you go to a page where there is a lot of celebrity images such as Jennifer Lopez it can take up to 10 seconds to go between page 1 and page 2.

    Can the server be better optimized for databases or do you think the script might be at fault?

    Its a hostgator server and i was told they are good for database driven site.

    Any ideas?
     
    articledirectory, Jan 8, 2008 IP
  2. 007c

    007c Peon

    Messages:
    611
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why would the database be slow? Images aren't stored in the db i hope? What you should do is get lighthttpd to serve the images.
     
    007c, Jan 8, 2008 IP
  3. articledirectory

    articledirectory Peon

    Messages:
    1,704
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Image information is stored in the database, for example when you click on a celebrity name it needs to know home many pictures there are for that celebrity and how many pictures to display per pages, content is dynamically created not static, all this information is obtain by querying the database, i think its more script based problems than server problem so i will put a project up on scriptlance to get it fixed i think.
     
    articledirectory, Jan 8, 2008 IP
  4. kissmyarse

    kissmyarse Peon

    Messages:
    100
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Agreed, there's no way a script like that should take a long time to execute.

    A simple;

    SELECT COUNT(`*`) FROM table WHERE CELEB=`J_LO`
    Code (markup):
    will take that server ~1/50th of a second. The script may be doing a lot of unecessary queries, which is slowing it down. Is there a debug mode with the script? It could give you some clues.

    Also, the images take a while to load, are they produced on-the-fly with ImageMagik or something?

    Good Luck!

    kma
     
    kissmyarse, Jan 8, 2008 IP
  5. articledirectory

    articledirectory Peon

    Messages:
    1,704
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There is a small resize script there that produces the smaller images, but essential it is just a scaled down version of the original image and it does not reduce the original file size.

    I am going to have to hire a programmer to sort this out as i am no good with databases.

    If anyone can help with the script for a reasonable fee please PM me if not i will get s project put on on scriptlance.

     
    articledirectory, Jan 8, 2008 IP
  6. ndreamer

    ndreamer Guest

    Messages:
    339
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i can help with the speed, the best thing to do in your case is caching, there does not seem to be much if any dynamic content on the page that can't be cached.
    i can implement a caching system for you.
     
    ndreamer, Jan 8, 2008 IP
  7. sickanimations

    sickanimations Peon

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I definitely agree with ndreamer - It should be resized into a cache image on the first load (or even before) and then loaded from the cache until the image is changed or deleted.
     
    sickanimations, Jan 9, 2008 IP
  8. Denn

    Denn Peon

    Messages:
    76
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    When the picture is uploaded it should have been resized. And then database just have to contain names on the files and a name of the person. This should not create a load like you are talking about.
     
    Denn, Jan 19, 2008 IP
  9. oc-scott

    oc-scott Active Member

    Messages:
    420
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    68
    #9
    If you are sure that the database queries are optimized and still you are facing slow database requests, then you should have to optimize mysql service configuration by modifying my.cnf file.
     
    oc-scott, Jan 19, 2008 IP