Jump to content

Saving JSON to a textfile, simple questions.


nuclein

Recommended Posts

Hi, I'm kind of new to this forum, so I'll just go ahead and write a little about myself and my project.

18 year old from Sweden, still in school. thats pretty much all about me, so my project:

the past months I've been developing a JavaScript game with php backend. To communicate between server and client i use JSON. This has been working great. There's just one little problem, storing all the data. At first everything was stored in textfiles. all the sensitive data was ofcourse encrypted. To organize the data i used different characters like the star (*) etc. But the big problem was that i was forced to deparse all data and the puzzle it back together. This bugged out sometimes, when the wrong data was received and bugged out the whole system. Thats when i decided to go with MySQL. This was great, and much more simple. there's just one problem. the system needed to be capable of holding 1000 players online at once which did not work since the server was forced to handle 4000 php request/second. Before i "only" needed to handle less than 500 php requests/second. So I began thinking of a solution.

 

My idea is:

*JavaScript sends the data to the php script.

*The php script checks that the file holding the data requested isn't already opened.

*The php script opens the file and decodes the content.

*The php script loops through the object and finds the index the person is looking for.

*The data in this "index-object" is changed to the value received in the first step.

*The data is encoded to json and saved to the file.

 

for one of the things I will use this for is player position.

So the player send his/her position to the php-script when he moves.

But when the player wants to get the other players data, its read directly from the file!

 

The only question is: Do you think thiswill be able to work?

Thank you for taking the time to answer!

//Daniel

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.