Hello, I have a question about databases. Specifically, I'm working with PHP and MySQL. I just got my site hosted on a VPS, and I used one vCPU core on the VPS because I'm scared I don't have my code setup properly to utilize more than one CPU. In the code, I retrieve some numbers, let's call these numbers X from my database, I do some manipulations on these numbers and then I store those numbers back into the database. PHP isn't built for multi-threading, as far as I know, so each PHP request gets handled by one CPU core. I'm concerned that if were to have more than one CPU core on the VPS, there would be multiple PHP processes retrieving and manipulating X from the database and I'm not sure if the integrity of the numbers X would be maintained. Like, each process would retrieve X, add one to it and store it back in the database. With multiple cores, I imagine that if each CPU core retrieved X and added one to it, and then stored it back, I'd have an inaccurate value of X at the end of the day. Please let me know how to go about handling these types of situations, I've heard of a queueing system but I've never used that before.
Unfortunately, I'm still a bit of a "code newbie" in many ways, so I don't have an answer to that particular technical problem. 😳
I think you're on the right track, though, with your train of thought.
I also think that this question is easily explicit enough for StackOverflow. Maybe a bit more whitespace and breaking into paragraphs, but I'd upvote the question over there and answer it if I knew the answer! 😆
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.