客户端向服务器发送信息并保存到数据库
在我的 C# 应用程序中,客户端应将日志发送到服务器,并且相同的日志必须保存在 SQL Server 数据库中。 我应该如何做到这一点:
- 客户端将日志保存在数据库中,服务器从数据库中读取 - 而不是(长延迟)
- 客户端将日志保存在数据库中并同时将它们发送到服务器
- 客户端仅发送到服务器,服务器将它们保存在数据库中
哪种方式更有效正确的?
编辑
LAN 网络中有很多客户端
In my C# app client should send logs to server and the same logs must be save in SQL Server database.
How should I do this:
- client saves log in DB and server read from DB - rather not (long delay)
- client saves log in DB and simultaneously sends them to the server
- client only send to server and server saves them in DB
which way is more correct?
EDIT
There's many clients in the LAN network
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的第二个选择是不行的!永远不要把一件事做两次。
我想说,如果您的客户端已经连接(并写入)到数据库,那么您的客户端也应该将任何日志直接写入数据库。 (选项 1)。在任何其他情况下,选项 3 似乎是最合适的。
Your second option is a no-go! Never do a single thing twice.
I'd say if your client already connects (and writes) to the database then your client should also write any logs directly into the database. (Option 1). In any other case option 3 seems the most appropriate.
让客户端仅与服务器通信。服务器将分析来自客户端的信息。然后,服务器将信息写入数据库和/或对客户端采取操作。这样,您就能够立即对客户端采取行动,并将信息保存在数据库中以供以后使用。这也是有道理的,因为只有一台计算机能够写入 SQL,而不是许多客户端都单独写入......
Have the client communicate only with the server. The server would analyze the information from the client. The server then writes the information to the database and/or takes action on the client. This way you get the ability to immediately act on the client and save the information in the database for possible use later. It also makes sense because then only one computer is able to write to SQL instead of your many clients all writing individually...