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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:20:28+00:00 2026-05-13T16:20:28+00:00

I maintain a custom built CMS-like application. Whenever a document is submitted, several tasks

  • 0

I maintain a custom built CMS-like application.

Whenever a document is submitted, several tasks are performed that can be roughly grouped into the following categories:

  1. MySQL queries.
  2. HTML content parsing.
  3. Search index updating.

Category 1 includes updates to various MySQL tables relating to a document’s content.

Category 2 includes parsing of HTML content stored in MySQL LONGTEXT fields to perform some automatic anchor tag transformations. I suspect that a great deal of computation time is spent in this task.

Category 3 includes updates to a simple MySQL-based search index using just a handful of fields corresponding to the document.

All of these tasks need to complete for the document submission to be considered complete.

The machine that hosts this application has dual quad-core Xeon processors (a total of 8 cores). However, whenever a document submits, all PHP code that executes is constrained to a single process running on one of the cores.

My question:

What schemes, if any, have you used to split up your PHP/MySQL web application processing load among multiple CPU cores? My ideal solution would basically spawn a few processes, let them execute in parallel on several cores, and then block until all of the processes are done.

Related question:

What is your favorite PHP performance profiling tool?

  • 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-05-13T16:20:28+00:00Added an answer on May 13, 2026 at 4:20 pm

    PHP is not quite oriented towards multi-threading : as you already noticed, each page is served by one PHP process — that does one thing at a time, including just “waiting” while an SQL query is executed on the database server.

    There is not much you can do about that, unfortunately : it’s the way PHP works.

    Still, here’s a couple of thoughts :

    • First of all, you’ll probably have more that 1 user at a time on your server, which means you’ll serve several pages at the same time, which, in turn, means you’ll have several PHP processes and SQL queries running at the same time… which means several cores of your server will be used.
      • Each PHP process will run on one core, in response to the request of one user, but there are several sub-processes of Apache running in parallel (one for each request, up to a couple of dozens or hundreds, depending on your configuration)
      • The MySQL server is multi-threaded, which means it can use several distinct cores to answer several concurrent requests — even if each request cannot be served by more that one core.

    So, in fact, your server’s 8 core will end up being used 😉

    And, if you think your pages are taking too long to generate, a possible solution is to separate your calculations in two groups :

    • On one hand, the things that have to be done to generate the page : for those, there is not much you can do
    • On the other hand, the things that have to be run sometimes, but not necessarily immediately
      • For instance, I am think about some statistics calculations : you want them to be quite up to date, but if they lag a couple of minutes behind, that’s generally quite OK.
      • Same for e-mail sending : anyway, several minutes will pass before your users receive/read their mail, so there is no need to send them immediately.

    For the kind of situations in my second point, as you don’t need those things done immediately… Well, just don’t do them immediately 😉

    A solution that I often use is some queuing mechanism :

    • The web application store things in a “todo-list”
    • And that “todo-list” is de-queued by some batches that are run frequently via a cronjob

    And for some other manipulations, you just want them run every X minutes — and, here too, a cronjob is the perfect tool.

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

Sidebar

Ask A Question

Stats

  • Questions 481k
  • Answers 481k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't have a Java-specific answer for you, but wrap… May 16, 2026 at 6:29 am
  • Editorial Team
    Editorial Team added an answer For the getElementById() call to work, the Document has to… May 16, 2026 at 6:29 am
  • Editorial Team
    Editorial Team added an answer First, I believe that your code has a bug in… May 16, 2026 at 6:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.