Question

I'm currently working on a chat application using vb.net and my current design uses an Application object that when users send messages, they are appended to the application object and when retrieving messages, they are just reading from where they left off in the object. The only alternative I could think of would be to have an MSSQL table where messages would be inserted to and read from using a key to know where the users last read left off. What are the pros and cons to each of these implementations, and is there a method that I'm overlooking that would be more ideal?

As far as I can see, the advantages to the application object would be speed because you don't need to open a connection every time you make a read or write, and locking isn't necessary when reading the object. The disadvantages would be an application object getting very large and taking up too much memory, and if the application pool goes down, the chat would be lost with the object.

Advantages to an MSSQL table would be the datas persistence and structured storage and retrieval. Disadvantages would be having to open a connection every time which I assume would cause performance issues and collisions when multiple people try sending a message at once.

The chat so far has had a high of 400 users and I'm expecting it to reach into the thousands so performance will definitely be a concern in the near future.

No correct solution

OTHER TIPS

Well, there is also one big disadvantage to using the Application object. It won't work if deploying to a webfarm, since the object is not shared across servers.

If those were your only two options then I'd definitely go with a database, for scalability reasons.

However, another approach you might want to look into, especially if this chat app is embedded in a web application, is using SignalR, which is basically built for this kind of scenario.

Here's a tutorial on how to create a simple chat application using SignalR: http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-getting-started-with-signalr-20

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top