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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:42:35+00:00 2026-06-08T23:42:35+00:00

I am using PHP’s fputcsv to log votes in an application we are making.

  • 0

I am using PHP’s fputcsv to log votes in an application we are making. The saving part of my code roughly ressembles this:

$handle = fopen('votes.csv', 'a');
fputcsv($handle, $data);
fclose($handle);

This works flawlessly in tests. However, I have a small concern. When deployed in production, it’s possible that many many users will be making a request to this script at the same time. I am curious as to how PHP will handle this.

Will I potentially have problems, and lose votes because of that? If so, what can I do to prevent it? Is the solution more complex than simply using a database? And finally, how can I test for this situation, where a lot of requests would be made at the same time? Are there things that already exist to test this sort of stuff?

  • 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-08T23:42:37+00:00Added an answer on June 8, 2026 at 11:42 pm

    Writing to a file can cause issues with concurrent users. If you instead insert into a database, you can let the database itself handle the queue. If you run out of connections, it is easily tracked and you can see the load on the db as you go.

    An insert in a database will be less resource heavy than an append to a file. Having said that, you would need pretty heavy load for either to take effect – but with a database, you have the build in query queue to alleviate a good portion of the concurrent stress.

    When you send a request to a database, it actually goes into a queue for processing. It only fails to be executed if there is a timeout in your PHP code (basically, PHP is told to abandon the wait for the db to respond – and you can control this via PHP and Apache settings) so you have a fantastic built-in buffer.

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

Sidebar

Related Questions

Using PHP, I am making an application similar to an online concierge service. I
Using PHP I echo out table rows in a loop like this: <?php /*
Using php-sdk I obtain pages in this way: $array = $this->instance->api( '/' . $fb_user
Using php i wants to make a join query across 2 database. This is
Using PHP I'd like to compare an actual ip address to part of one,
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Using PHP's ReflectionClass. Is this possible? I want to get a list of methods
Using PHP to try and tackle this problem, but open to other solutions (Python,
Using PHP, given a string such as: this is a <strong>string</strong> ; I need
Using PHP, I am building an application that is MySQL database resource heavy, but

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.