从多个工作站收集数据

发布于 2024-07-22 07:14:13 字数 262 浏览 4 评论 0原文

我目前正在开发一个Windows 服务,该服务将部署到公司内的所有工作站。 该服务的目的是收集各种统计数据并将其记录在一个中央位置。

对于第一次迭代,服务直接调用 SQL 来记录每次有数据需要记录的情况。 在大约 120 个工作站上进行测试告诉我,这不是一个好主意,而且无法扩展。

有人可以推荐一种收集相关数据的替代策略,该策略不会使数据库服务器超载吗? 这将部署到大约 2000 台机器。

我正在使用 C#。

谢谢。

I'm currently working on developing a windows service which will be deployed to all the workstation within the company. The purpose of the service is to collect various statistics and record them in a central location.

for the first iteration, the service is doing direct call to SQL to record the every time there is data to record. Testing it on about 120 workstation told me that it is not a good idea and won't scale.

Can someone recommend an alternative strategy for collecting the data in question which won't overload the database server? This will be deployed to about 2000 machines.

I'm working with C#.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

各自安好 2024-07-29 07:14:13

从您的问题来看,您似乎已经有了一个可行的解决方案,您只需要有关如何扩展它的建议。 以下是我的两点建议:

  • 不要在工作站的服务中保持 SQL 连接打开
  • 尝试在内存中批量更新数据,并且仅在收集到一定数量的数据或经过一定时间间隔后才更新数据库(使您的连接不那么频繁)更矮胖)。
  • 确保您的数据库正确规范化,以避免重复数据

就个人而言,对于需要扩展到 2000 个工作站的关键任务,我会使用商业产品,并且不会重新发明轮子。

From your question, it appears that you already have a working solution and you just need advice on how to make it scale. Here are my two cents:

  • Do not keep the SQL connections open in the workstation's service
  • Try batching data updates in memory and only update the database after a certain amount of data has been collected or a certain interval has passed (making your connection less chatty and more chunky).
  • Make sure your database is properly normalized to avoid duplicate data

Personally, for something mission-critical that requires it to scale to 2000 workstations, I would use a commercial product and would not re-invent the wheel.

没有伤那来痛 2024-07-29 07:14:13

只是回答来总结问题。 这是我最终实现它的方式。

数据收集

  • AC# 服务在工作站上运行。 它以不同的时间间隔(不是预先确定的,基于系统上的某些事件)触发数据收集。
  • 数据被写入本地工作站上的文件中。
  • 然后数据文件被复制到网络位置。

数据解析

  • “导入器”程序按计划运行。 它会遍历自上次运行以来创建的所有文本文件,解析它们并将它们导入到 SQL 中。

我以这种方式实现它的原因是:

  • 避免我在原始问题中提到的 SQL 服务器的资源问题。
  • 创建的文件非常小,1-2KB
  • 导入器会在过去运行几分钟,以避免与正在进行的任何副本发生冲突。
  • 导入器删除已处理的文件并跳过不在其“lastscantime”和“currentTime-X 分钟”窗口内的文件。

Just answering to wrap up the question. Here is how I ended up implementing it.

Data Collection

  • A C# service runs on the workstations. At different intervals (not predetermined, based on certain events on the system) it fires off data collection.
  • Data is written to a file on the local workstation.
  • Data file is then copied to a network location.

Data Parsing

  • An "importer" program runs on a schedule. It goes through all the text files created since it last ran, parses them and imports them into SQL.

The reason I implemented it this way is to:

  • Avoid resource issues with my SQL server that I mentioned in the original question.
  • Files created are really small, 1-2KB
  • Importer runs a couple of minutes in the past to avoid colliding with any copies in progress.
  • Importer deletes the files which have been processed and skips the files which are not within it's "lastscantime" and "currentTime-Xminute" window.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文