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 7884273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:45:18+00:00 2026-06-03T04:45:18+00:00

I have an image serving script in PHP that I have been optimizing. I

  • 0

I have an image serving script in PHP that I have been optimizing. I have been working a lot on the server-end of optimization, but I also want to make sure I optimize the mysql side of things. I currently have the following actions being taken with MYSQL on each loading of this image serving script.

  1. Connect to the database
  2. Check to see if the id provided is valid and return the row if it is
  3. Update the stats of the image by increasing the number of hits column by 1
  4. Increment the stats table with the specific controller and action by 1 as well
  5. I don’t close the connection, i was told to let it sit as it takes less time and it will die on it’s own

I ran “mysqladmin status” on my server and found out there were 63.8997 avg being run at the moment. I currently have around 17 req/s going through apache loading this script. I also have eaccelerator configured on the server to keep a compiled version of this script ready to use. My question is are there any ways I can further optimize the number of queries i can process? I am trying to make sure I keep all the #s as low as I can possibly do and moving as fast as I can?

My goal is to have my server handle 4.32 million image serves a day with no issue (that’s 50/req a sec in apache).

  • 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-06-03T04:45:19+00:00Added an answer on June 3, 2026 at 4:45 am

    Everytime you increment the counter and commit it to the DB, you probably will be writing to the disk. Instead, you can try caching the number of hits in memory for a few minutes, and every few minutes dump the cache back into the database. This will reduce the number of writes and reads you have on the database.

    You can also go a step further in caching the entire row in memory. This will only be practical if the data doesn’t change very often, and if the data is requested very often. Also, memory constraints may become an issue if you start caching huge amounts of data.

    I know in some very high performance database environments, the entire database instance will be stored in memory, and writes to the disk will only occur periodically. This would also drastically decrease query times, and reduce the need for caching as everything would already be in memory. This would require some serious hardware though.

    Additionally, you may want to eventually move away from MySQL. MySQL isn’t the best for high performance, namely becausse MySQL and stored procedures don’t go hand in hand very well. Stored procedures are compiled on the database, and don’t require parsing of SQL in order to be executed. If you were to switch to something, like Oracle for example this entire transaction could be done with a compiled stored procedure. MySQL doesn’t easily provide this flexiblity, if at all.

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

Sidebar

Related Questions

I have a server (VPS) that hosts numerous PHP / MySQL websites. Most are
I have image data and i want to get a sub image of that
I have managed objects that have image properties. Since storing large blobs in CoreData
Hey guys currently I am thinking of serving images using an image handler script.
I have a WCF service serving image per request. Accessing the service via localhost
I have been developing a book viewing website that takes rather large images (upwards
I'm working on a web app in ASP.NET 2.0 that involves serving images via
In order to save precious bandwidth, the image serving app (a minor, but important
I've been considering image hosting services for a project but am starting to wonder
I am working on PHP wrapper for Google Image Charts API service. It supports

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.