Create a shared workspace with ASP.NET and Ajax

Here is a hypothetical situation that I have been interested in recently. Suppose I have an interactive page created in ASP.NET and Ajax, and I want several users to be able to manipulate at the same time. What would be the best way to maintain this page state? Especially if the page was relatively ephemeral and especially did not need to be stored in the database?

As a concrete example, suppose that I am implementing a basic game of checkers. The server must constantly maintain the state of the board. Customers need to periodically check the status of the board and be able to transfer their changes to the board. When all the players leave, or when the game ends, the board is no longer needed, and the server can get rid of it.

I could store everything in the database, retrieve it when clients request a board update, and save it when the server receives the update. But this seems like a lot of extra overhead.

What about static variables? How reliable are they / effective enough for this job? Is there any other storage mechanism I could use? Or is it so far beyond what ASP.NET can do efficiently that I have to look at a completely different technology if I ever want to implement this?

Update:
One quick update to find out if I can get another round of answers. After a bit of research, here's what I still have:
Manu suggested using MemCached on my own to store data. I like that this solution works even in multi-server environments, but I noticed several drawbacks:
1) The MemCached website states that it is designed for high-strength applications (that this does not apply to a traditional web application) and that it is "unreliable". I didn’t get far enough to determine how important these characteristics are (i.e. Is writing slowly? Is there a propagation delay?).
2) In an implementation close to my application (storing session data), the MemCached site uses the database cache, although the data does not need to be saved.
3) I have some doubts as to how useful MemCached will be in a hosted environment.

Looking at static variables, they seem to be fast. They are not thread safe, but this can be explained. However, they are local to the workflow, so I'm not sure how they work with load balancing or a web garden.

Finally, there is at least one ASP.NET-based chat client implementation (VERY similar to this example) that uses the databases as the source. With proper caching, this may just be "good enough."

+3
source share
2 answers

. (, 5 ?) , .. , JSON-RPC ( x), .

ASP.NET, , , - PHP, , , PHP, . Infact, , ASP.NET - . , , , , - .

+1
+1

Source: https://habr.com/ru/post/1697954/


All Articles