3

I've implemented a type of in memory database using generic Lists and Linq and it is consumed by an ASP.NET application. Building this database in memory takes about 45 seconds (it's built from a database) so we're trying to minimize ASP.NET app pool recycles to once a day at 1:00 a.m. to avoid having the worker process recycle in the middle of the day and spin for 45 seconds rebuilding the database.

I'd like to move our in memory database to another process isolated from the ASP.NET worker process but I'm unsure as to how I can get objects in the ASP.NET application talking to a separate process that would hold the database. Should I use a TCP listener type of thing? I know IIS used to be able to host libraries and make them available via remoting...is this still possible?

If you're wondering why I'm going to all the trouble of an in memory database it's because it's powering a faceted search application. Using Linq and in memory lists is faster by many orders of magnitude than going to the database for each search.

Thanks in advance for any advice.

Craig Koster
  • 496
  • 5
  • 15
  • but is interprocess communication faster than DB queries? – Matt Ellen Jun 15 '11 at 14:01
  • 1
    @Matt, if the DB is on the network and used by other apps as well, IPC on a process on the same machine which has everything already in memory should be faster in my opinion. – Davide Piras Jun 15 '11 at 14:14
  • 1
    Did none of the other in memory databases or the built in [asp.net caching](http://msdn.microsoft.com/en-us/library/ms178597.aspx) meet performance requirements? – Roman Jun 15 '11 at 14:15
  • IPC is quite quick if you are on the same machine. DB queries, especially if they are hitting disk, are hundreds of times slower than in-memory access, even with IPC overhead. – Chris Shain Jun 15 '11 at 14:16
  • Matt - faceted search doesn't lend itself well to traditional relational database models. That's why I went with a custom object based in memory database. – Craig Koster Jun 15 '11 at 14:59

3 Answers3

2

You should probably look at WCF over named pipes: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication.

You could host your DB in a simple windows service.

Chris Shain
  • 50,833
  • 6
  • 93
  • 125
2

Named pipes are one option to do it. You can abstract that away to an extent using WCF Named Pipes bindings. You can also apply security permission to said named pipes to improve security against arbitrary applications doing stuff to your in memory database.

Community
  • 1
  • 1
Roman
  • 19,581
  • 6
  • 68
  • 84
1

CK1, WCF and Named Pipes as other said are fine within the same server, if you would then put in another machine ( like an application server ) your in memory db hosting, you could simply change the binding and use netTCP for fast binary communication across machines over TCP...

Davide Piras
  • 43,984
  • 10
  • 98
  • 147