tl;dr
The resources should only be controlled by the server Server
(securely) as a decision making entity; The actual work could be offloaded to Clients
and later verified lazily by the Server
.
Long story:
How often you update the resources is up to you, your hardware and desired gameplay experience. I don't see why it requires you to update every second but? What about every 10 seconds? But if it does, I am sure it is entirely possible with the right hardware. BesidesRemember, some data that changes frequently could be stored in game memory and only updated to database for storage / backup purposes (with constraint validation).
When a user logs in (assuming production continues when offline) you, one could simply check the last date the user was online, how much X
resource she had and use that to calculate theher current amount of cashresource X
. The rest of the timeWhen she plays, you could let the client canher handle the money, again checking if she is cheating by verifying constraints online. When the client makes a transaction, you could check that the current amount of cashresource X
corresponds with the constraints (what the clients claims matches what the server thinks), calculating the resource state and leaving a tiny buffer for synchronization.
It all depends on the complexity of the game. In general I think you are doing three things that don't necessarily mix well (if taken to extreme) but could work fine depending on your server hwHW.
- Update theUpdating game state very frequently.
- KeepStored all data stored on a server sideDB.
- Run the game as a php appHTTP POST/GET requests, not a concurrent game server.
Again, I don't see why updating every second should be a huge concern but some benchmarks and tests you could easily perform would alleviate or affirm your suspicions. Then you could lower the rate of updates and/or employ a different strategy (offloading some of the work to client-side [Angular]) or something like that.