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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:58:42+00:00 2026-06-02T22:58:42+00:00

I wrote the following script as a test and it appears it’s only being

  • 0

I wrote the following script as a test and it appears it’s only being server to two clients at a time:

<?php
$time = time();
$timediff = 0;

do
{
    $timediff = time() - $time;
    usleep(1);
}while($timediff <= 1);

echo date('G:i:s', $time)." - ".date('G:i:s', time()); 
?>

Result for a LAMP server:

lamp_results

Each thread seems to be correctly started at the same time, confirmed by the result (what php echo’d back) and every 2 new threads to indeed take an extra 2 seconds (time) to finish.

Each script seems to be taking 2 seconds to finish, after which the following 2 are served. This is just stupid, because now I have a quad core 3.2 GHz server with 12GB RAM queueing people for no good reason. It may be worth to mention that according to htop (a system monitor) only two CPU cores are being used by apache2.

I tried the script again on a debian-squeeze server running lighttpd and php5-fpm, which is a completely different setup, but it gave the same results. I’m not sure if it’s bad coding or something else..

I already tried commenting out the usleep() but that nets the exact same results, except for the fact that htop then shows CPU usage at 100% on all (both) cores. With usleep on 1 it shows a usage of 15% on each core, and with usleep on 500 it’s barely reaching 6% each, confirming that the server should be able to serve way more pages than 2 at a time.

Can anyone tell me why this happens?

  • 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-02T22:58:46+00:00Added an answer on June 2, 2026 at 10:58 pm

    How exactly are you running those tests? If your benchmarking-software only does 2 requests simultaneously, it makes sense you only get 2 at a time.

    You could try out ab also known as apache benchmark. You can set the amount of simultaneous request using a parameter.

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

Sidebar

Related Questions

I wrote the following script, which generates a SyntaxError : #!/usr/bin/python print Enter the
I have an interesting problem. I wrote the following perl script to recursively loop
following is the bash script I wrote for Sqlite. #!/bin/bash sqlite3 file.db CREATE TABLE
I have the following dummy test script: function test() { var x = 0.1
I wrote the following pre-commit script for SVN to validate that a user has
I have the following simple page; <%@ Import namespace=System.IO %> <script runat=server> int pageSize
I tried the following script: #!/bin/bash var1="Test 1" var2="Test 2" if [ "$var1"="$var2" ]
I have a script, called test.py , that does the following: while (1): ....print
When we run following script under Firefox ... var d = $(<div class='test'></div>); d.hide();
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I

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.