The approximate process of the system is as follows: Receive the packet from the data center (10,000 ~3 million)/sec, using WCF can be used by different scenarios, each of which has the same business logic, and each scenario receives the same code for the packet part, and then uses a container to all the "scenario DLL "Loading by reflection, while the container receives all packets and sends them to the" Application scenario DLL ", the ability to receive data is naturally abstracted into interface. A thorough point is a plug-in system, but this plug-in is a bit large, large to the entire system is a plug-in. This container we call him "engine" for the time being, and this "scene dll" we call him "rules" for the time being.
My ideal approach is that each rule (one or more DLLs) is placed under a single folder and has its own configuration file. When the engine is started, a new AppDomain is created for each rule according to the engine's configuration, and the configuration file is also set for the AppDomain, while the new AppDomain load corresponds to the DLL. The currentdomain of the engine holds the MarshalByRefObject of each rule, and when the engine receives the data, it distributes the data to the corresponding rules according to some conditions. Russia, the engine looks a bit like an IIS Ah!!!
Wait, such a wonderful idea, so easy to achieve?! Did I forget something? Oh I forget the rules of the MarshalByRefObject can withstand 10,000 ~ 30,000 calls per second (the call here is to pass the packet).
[In the afternoon system test, the performance technology device shows that only about 2000 packets per second are processed and the rest is lost ... Crazy in the middle of the gloom]
Since the last net technology assembly back, every day is very busy, a lot of lectures have not time to aftertaste, see Old Zhao and Eaglet are codetimer, ashamed ah, but just bring over to use it. The test code is as follows:
1. Funa () Funb () FunC () FunD () is the test code, class Remoterproxy is easier to create a remote object, not a proxy model OH.
1namespace Appdomainperformancedemo
2{
3 class Program
4 {
5 const int COUNT = 500000;
6
7 static void Main (string[] args)
8 {
9 Funa ();
Funb ();
FunC ();
FunD ();
13
Console.ReadLine ();
15}
16
17
static void FunC ()
19 {
remoterproxy remoterproxy = new Remoterproxy ();
codetimer.time ("Remoterproxy:same AppDomain", COUNT, Remoterproxy.funtest);
22}
23
static void FunD ()
25 {
AppDomain domain = appdomain.createdomain ("Newappdomain");
remoterproxy remoterproxy = (remoterproxy) domain. Createinstanceandunwrap (assembly.getexecutingassembly (). FullName, "Appdomainperformancedemo.remoterproxy");;
codetimer.time ("Remoterproxy:across AppDomain", COUNT, Remoterproxy.funtest);
appdomain.unload (domain);
30}
31
static void Funb ()
33 {
iinterface inter = New Implementa ();
codetimer.time ("Implementa:same AppDomain", COUNT, Inter. Funa);
36}
37
static void Funa ()
39 {
AppDomain domain = appdomain.createdomain ("Newappdomain");
Remoterproxy remoterproxy = (remoterproxy) domain. Createinstanceandunwrap (assembly.getexecutingassembly (). FullName, "Appdomainperformancedemo.remoterproxy");;
iinterface inter = remoterproxy.createinstance ("Appdomainperformancedemo.implementa", "MyImplement", Bindingflags.createinstance, NULL);
codetimer.time ("Implementa:across AppDomain", COUNT, Inter. Funa);
appdomain.unload (domain);
45
46}
47}
48
public class Remoterproxy:marshalbyrefobject
50 {
Wuyi Public IInterface CreateInstance (string typeName, String AssemblyName, BindingFlags BindingFlags, object[ ]
Constructorparams)
52 {
Assembly owningassembly = Assembly.Load (AssemblyName);
54
IInterface Instancehandler = owningassembly.createinstance (typeName) as iinterface;//, false, BindingFlags, NULL, constructorparams, NULL, NULL) as IInterface;
56
return instancehandler;
58}
59
public void Funtest ()
61 {
62}
63}
64
65
66}
67