Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good C#.NET Solution to manage frequent database polling

I am currently working on a c# .NET desktop application that will be communicating to a database over the internet via WCF and WCF Data Services. There will be many spots in the application that may need to be refreshed upon some interval. The easiest solution would be to just put these areas on a timer and requery the database. However, with thousands of clients connecting to the service layer and hence database, these operations would be very expensive to the server.

What I have considered is creating an RSS feed that is polled by the client, and lets the client know when these particular areas need to be updated. The RSS feed will be managed by a service that either polls the database for changes, or iterates through a list of items that are queued up by the WCF requests made by the client.

I have also considered creating some direct and continuous connection from the client to the server, but I am not sure what outbound firewall ports would be open from the client. I could probably only count on port 80/443.

So my question is what solutions have people had success implementing to solve this problem? Have people done RSS? Microsoft Sync Services? Two way communication between client and server over some save port via WCF?

like image 415
BernicusMaximus Avatar asked Dec 07 '10 16:12

BernicusMaximus


People also ask

What is a good C?

The Good C contains a concentration of 5% vitamin C that is safe and gentle. Higher concentrations do not remain stable on the skin and can trigger inflammation and damage the skin's barrier function.

What is vitamin C serum used for?

The cosmetic industry is full of serums that promise to make your skin glow. Of the many serums available, vitamin C serum is proven. Vitamin C is a powerful antioxidant that works to stimulate collagen production in your skin. It also fights fine lines, brightens your complexion, and provides a host of other benefits.

What is THD vitamin C?

Tetrahexyldecyl ascorbate (THD) is a highly stable form of vitamin C that is considered an analogue of L-ascorbic acid. Enzymes within skin convert this form of vitamin C to pure vitamin C, ascorbic acid. Unlike pure vitamin C (ascorbic acid), tetrahexyldecyl ascorbate is lipid (fat) soluble.

How do you use Barbara Sturm's sun drops?

Apply SUN DROPS SPF 50 liberally 15 minutes before sun exposure and reapply as directed. Avoid the midday sun and reapply frequently to maintain sun protection as directed, especially after perspiring, swimming or drying off with a towel. Do not overexpose yourself to the sun, even if you're using SUN DROPS SPF 50.


2 Answers

I think you might want to go with a combination of two approaches. First off, you could use long polling from the client to server so that the server can notify the client as soon as a change occurs that the client is interested in.

A new technology that handles the above suggestion quite nicely in ASP.NET is SignalR. This handles much of the details of long polling (or uses WebSockets when it can) so you don't have to worry about it.

Secondly, based on the tags in this question it looks like you're using SQL Server. You could use database notifications on the tables you are interested in to have the DB notify your service when changes occur. This could then trigger the service to notify the client about the changes through the long poll connections. You can do this using the SqlDependency class.

I'm sure there are other ways, but this would probably scale quite well as you'd only have one service getting the notifications and then distributing them out to all the clients.

like image 181
Jeremy Wiebe Avatar answered Nov 07 '22 19:11

Jeremy Wiebe


you can define a callback interface in the WCF connection like this:

[ServiceContract(CallbackContract = typeof(IFooClient))]

As the client initiates the connection the should work through the firewall. The the server can method to register for changes an you can get the callback interface with

IFooClient client = OperationContext.Current.GetCallbackChannel<IFooClient>();

and callback all the clients that are registered on data changes.

like image 45
Kolja Avatar answered Nov 07 '22 18:11

Kolja