0

i have coding a web application which has multi user. they are select data or insert data every thing is that. But selecting some data need too many time such as using LINQ or mathematical calculation. i thing that: my user1 :

select * from MyTable -----> save as caching via proxy server in machine

my user2 :

select * from MyTable2 -----> save as caching via proxy server in machine

my user3 :

insert into MyTable2 -----> Update caching(select * from MyTable2) via proxy server in machine

How to write a proxy server to select Faster and update select result if another user update table?

enter image description here

abatishchev
  • 98,240
  • 88
  • 296
  • 433
loki
  • 2,926
  • 8
  • 62
  • 115
  • 1
    I would suggest using a pre-existing caching solution instead of writing a new one from scratch – Eric Mar 17 '11 at 09:59
  • I don't know if this applies to your situation or if you just used a simplified example, but using `WHERE` clauses on your SELECT (and selecting only the required fields instead of `*`) might improve performance much more than manually caching the data. Remember that database access is usually *very fast* (when indexes are in the right places and you only request the data that is really needed) and that network connections between machines on the same subnet are usually fast as well. Did you do benchmarking to find out where your performance bottlenecks lie? – Heinzi Mar 17 '11 at 10:04
  • So you want something that keeps recently/frequently selected rows available in memory, and ensures that any updates that are made to the tables are reflected in those in memory rows, whilst dealing with memory pressure, etc? That sounds like what SQL Server is already doing internally (and doing a mighty fine job of it, most of the time). – Damien_The_Unbeliever Mar 17 '11 at 10:29

2 Answers2

1

I guess I understand what you mean. If you want to achieve the result shown on your drawing, then one way would be to have server cache all the data which is requested by any machine. I think this is too much overhead in terms of the memory, but you can accomplish this in many ways. For example, create a proxy class which handles all database calls and then caches the results. Whenever next call is done, the handler class checks the proxy and returns if such exists; if not, then it makes a call and adds results to the cache.

BTW, I think this part is already taken into account by existing ORMs, no?

Tengiz
  • 8,011
  • 30
  • 39
  • i don't understand last sentence: "BTW, I think this part is already taken into account by existing ORMs, no?" – loki Mar 17 '11 at 11:17
  • ORM = Object Relational Mapping. In simple words this is common name for Entity Framework, Linq To Sql, NHibernate. I guess they all already have this built-in into them right out of the box. oh, and BTW= By The Way :-) – Tengiz Mar 17 '11 at 11:19
0

Why would you want a Proxy for that?

What you want to accomplish is one of the benefits of use ADO Entity Framework

You have tutorials everywhere in the web, but you can start with this one

ADO Entity Framework is smart enough to cache objects that are used many times and refresh them when they are not in sync, they also have a series of fantastic properties like late-binding and concurrency handling.

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • balexandre; i think that you don't understand me. also i am a professional in entity framework.Thanks advise. but i don't want to re generate data i save select result in another machine – loki Mar 17 '11 at 10:05
  • why will you wnat to handle one more machine (one more connection, one more license, one more everything) and not do things properly? ORM + Caching will work for you out of the box, no need to reinvent the wheel ! – balexandre Mar 17 '11 at 10:09
  • ok;) But i have to use linq to sql caching is ok in linqtosql? – loki Mar 17 '11 at 10:19