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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:35:21+00:00 2026-05-16T02:35:21+00:00

If there is a HTTP request coming to a web server from many clients

  • 0

If there is a HTTP request coming to a web server from many clients the requests will be handled in the order.

For all the http request i want to use a token bucket system.
So when there is a first Request i write a number to a file and increment the number for the next request and so on..

I dont want to do it in DB since the DB size increases..

Is this the right way to do this.Please suggest

Edit:So if a user posts a comment the comment should be stored in the a file instead of the DB.So to keep track of it there is a variable that is incremented for every request.this number will be used in writing the file name and refer it for future reference.so if there are many requests is this the right way to do it..

Thanks..

  • 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-16T02:35:22+00:00Added an answer on May 16, 2026 at 2:35 am

    Why not lock ( http://php.net/manual/en/function.flock.php ) files in a folder ?

    First call locks 01,
    Second call locks 02,
    3rd call locks 03,
    01 gets unlocked,
    4th call locks 01

    Basically each php script tries to lock the first file it can and when it’s done it unlocks/erases the file.

    I use this in a system with 250+ child processes spawned by a “process manager”. Tried to use a database but it slowed down everything.

    If you want to keep incrementing the file number for some content i would suggest using mktime() or time() and using

    
    $now=time();
    $suffix=0;
    while(is_file($dir.$now.'_'.$suffix)) {
      $suffix++;
    } 
    

    But again, depending on how you want to read the data or use it, there are many options. Could you provide more details?

    —–EDIT 1—–

    1. Each request has a “lock-file”, and stores the lock id (number) is in $lock.
    2. three visitors post at the same time with the lock-id 01, 02, 03 (the last step in the described situation)
    
    $now=time();
    $suffix=0;
    $post_id=30;
    $dir='posts/'.$post_id.'/';
    if(!is_dir($dir)) { mkdir($dir,0777,true); }
    while(is_file($dir.$mktime.'_'.$lock.'_'.$suffix.'.txt')) {
      $suffix++;
    }
    

    The while should not be neede but i usually keep it anyway just in case :).
    That should create a txt file 30/69848968695_01_0.txt and ..02_0.txt and ..03_0.txt.

    When you want to show the comments you just sort them by filename….

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

Sidebar

Related Questions

I want to find location of http request that are coming from many countries.
I'm looking for ways to detect/estimate the country from which a http-request is coming
Is there a way to access the http request IE made when the page
Is there any way to easily make a HTTP request with C++? Specifically, I
There is a standard header for giving a digest of an HTTP request body
Is there anything non-RESTful about providing parameters to a HTTP DELETE request? My scenario
What's the maximum length of an HTTP GET request? Is there a response error
I request a website header, however, there is not Last-Modified info in this http
I want to pass these parameters with a HTTP request to a WebApp hosted
I am trying to put some logging to capture the raw http request coming

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.