Sockets,Polling, socket-less results?

别来无恙 提交于 2019-12-11 02:19:58

问题


I'm developing a Windows Form application which runs on a cloud SQL service hosted by the Microsoft Azure development services. Without having the ability to physically have a receiving application which would allow me to utilize sockets which is an essential pitfall as my application would rely heavily on a dedicated database, so i'd prefer to have the ability to constantly check the database for changes and alert the current user based on row entries which match criteria.

I've read on a few blogs/posts that polling (Was a possible solution) is a bad thing to utalize. So, what would be an approach to consider?


回答1:


To clarify the problem, you want clients to receive updates when certain data changes in the database.

SQL Server 2005 and 2008 do support the concept of notifying clients when data changes (MSDN). However, this SO question would seem to indicate that this feature is not present in SQL azure at this time. This means that you have a few options:

  1. Poll the database itself

    • This option lets you keep costs down, as you already have everything you need. The disadvantage of course is that you are doing (potentially large) queries at a relatively frequent interval. With enough clients this will drastically slow down due to the load involved. It could also prove costly if you have a price/transfer scheme.
  2. Wrap a service around the database and talk to that

    • This could be used with polling, but is even better when using a push technology (like sockets or WebSockets). This of course has additional upfront costs, but allows you to control what updates are received and when. Ideally, this service would keep a copy of the database in-memory that it used to service client requests, while updating the actual DB on its own. This keeps queries to the database (which are slow) at a minimum.

Only you know the right answer for this, but I would go with the second. It will be more performant, scale better, and prove more extensible when you need functionality that goes beyond simple queries.



来源:https://stackoverflow.com/questions/25456898/sockets-polling-socket-less-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!