简体   繁体   English

WCF - 解决方案架构

[英]WCF - solution architecture

I am working on a project in which a WCF service will be consumed by iOS apps. 我正在开发一个项目,其中iOS应用程序将使用WCF服务。 The number of hits expected on the webserver at any given point in time is around 900-1000. 在任何给定时间点,网络服务器上预期的点击次数约为900-1000。 Every request may take 1-2 seconds to complete. 每个请求可能需要1-2秒才能完成。 The same number of requests are expected on every second 24/7. 预计每秒24/7的请求数量相同。

This is what my plan: 这就是我的计划:

  1. Write WCF RESTful service (the instance context mode will be percall). 编写WCF RESTful服务(实例上下文模式将是percall)。
  2. Request/Response will be in Json. 请求/回复将在Json。
  3. There are some information that needs to be persisted in the server - this information is actually received from another remote system - which is shared among all the requests. 有些信息需要保留在服务器中 - 这些信息实际上是从另一个远程系统接收的 - 在所有请求之间共享。 Since using a database may not be a good idea (response time is very important - 2 seconds is the max the customer can wait), would it be good to keep it in server memory (say a static Dictionary - assume this dictionary will be a collection of 150000 objects - each object consists of 5-7 string types and their keys). 由于使用数据库可能不是一个好主意(响应时间非常重要 - 客户可以等待的最长时间为2秒),将它保存在服务器内存中会很好(比如静态字典 - 假设这个字典将是一个150000个对象的集合 - 每个对象由5-7个字符串类型及其键组成)。 I know, this is volatile! 我知道,这很不稳定!
  4. Each request will spawn a new thread (by using Threading.Timers) to do some cleanup - this thread will do some database read/write as well. 每个请求都会产生一个新线程(通过使用Threading.Timers)来进行一些清理 - 这个线程也会做一些数据库读/写。

Now, if there is a load balancer introduced sometime later, the in-memory stored objects cannot be shared between requests routed through another node - any ideas? 现在,如果稍后引入了负载均衡器,则无法在通过另一个节点路由的请求之间共享内存中存储的对象 - 任何想法?

I hope you gurus could help me by throwing your comments/suggestions on the entire architecture, WCF throttling, object state persistence etc. Please provide some pointers on the required Hardware as well. 我希望你的大师可以通过抛出你对整个架构,WCF限制,对象状态持久性等的意见/建议来帮助我。请提供一些关于所需硬件的指示。 We plan to use Windows 2008 Enterprise Edition server, IIS and SQL Server 2008 Std edition database. 我们计划使用Windows 2008 Enterprise Edition服务器,IIS和SQL Server 2008 Std版数据库。

Adding more t #3: As I said, we get some information to the service from a remote system. 添加更多t#3:正如我所说,我们从远程系统获取服务的一些信息。 On the web server where the the WCF is hosted, a client of the remote system will be installed and WCF references one of this client dlls to get the information, in the form of a hashtable(that method returns a hashtable - around 150000 objects will be there in this collection). 在托管WCF的Web服务器上,将安装远程系统的客户端,并且WCF引用此客户端dll之一以获取信息,以哈希表的形式(该方法返回哈希表 - 大约150000个对象将在这个集合中)。 Would you suggest writing this information to the database, and the iOS requests (on every second) which reach the service retrieves this information from the database directly? 您是否建议将此信息写入数据库,并且到达服务的iOS请求(每秒一次)直接从数据库中检索此信息? Would it perform better than consuming directly from this hashtable if this is made static? 如果这是静态的,它会比直接从这个哈希表中消费更好吗?

Let me throw some comments/suggestions based on my experience in serving a similar amount or request under the WCF framework, 3.5 back in the days. 让我根据我在WCF框架下提供类似金额或请求的经验,提出一些意见/建议,3.5。

I don't agree to #3. 我不同意#3。 Using a database here is the right thing to do. 在这里使用数据库是正确的做法。 To address response time, implement caching and possibly cache dependency in order to keep the data synchronized across all instances (assuming that you are load balanced)(also see App Fabric suggested above/below). 为了解决响应时间,实现缓存和可能的cache dependency ,以便在所有实例之间保持数据同步(假设您负载均衡)(另请参阅上面/下面建议的App Fabric)。 In real world scenarios, data changes, often, and you must minimize the impact. 在现实世界的场景中,数据经常会发生变化,您必须尽量减少影响。

We used Barracuda hardware and software to handle scalability as far as I can tell. 据我所知,我们使用Barracuda硬件和软件来处理可扩展性。

Consider indexing keys/values with Lucene if applicable. 考虑使用Lucene 索引 keys/values (如果适用)。 Lucene delivers extremely good performances when it comes to read/write. Lucene在读/写方面表现出色。 Do not use it to store your entire data, read on it. 不要用它来存储你的整个数据,阅读它。 A life saver if used correctly. 如果使用正确,可以节省生命。 Note that it could be complicated to implement on a load balanced environment. 请注意,在负载平衡环境中实现它可能很复杂。

Basically, caching might be the only necessary change to your architecture. 基本上,缓存可能是您的架构唯一必要的更改。

Since you are using Windows Server 2008 I would definitely use the Windows Server App Fabric Cache to store your state: 由于您使用的是Windows Server 2008,我肯定会使用Windows Server App Fabric Cache来存储您的状态:

http://msdn.microsoft.com/en-us/library/ff383813.aspx http://msdn.microsoft.com/en-us/library/ff383813.aspx

It is free to use, well supported and integrated and is (more or less) API compatible with the Windows Azure App Fabric Cache if you every shift your service to Azure. 如果您将服务转移到Azure,它可以免费使用,得到良好支持和集成,并且(或多或少)与Windows Azure App Fabric Cache兼容。 In our company (disclaimer: not my team) we used to use MemCache but changed to the App Fabirc Cache and don't regret it. 在我们公司(免责声明:不是我的团队)我们曾经使用MemCache但改为App Fabirc Cache并且不后悔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM