caching - Most efficient way of storing database information in memory using C# -


i busy experimenting things in c#, can build web server liking. web server specially made project i'm working on. in hope run better other web servers.

now i've been trying find efficient way store database information in memory of application.

so far i've tried making class resembles table it's fields. creating new instance of class every row in table. create dictionary variables resembles indexes. 1 id, 1 username. it's working, consumes 3x memory compare table in database. example of i've done:

class user() {     public int id;     public string name;     //other columns, same way } 

as dictionary:

dictionary<int, user> useridindex = new dictionary<int, user>(); user newuser = new user(); newuser.name = "something..."; useridindex.add(someid, newuser); 

i've tried datatable, wasn't success @ all. consumed @ least 50% more memory class , dictionaries method.

i curious if there's other way, more efficient way of storing information?

reason behind this: lot of data needs updated , selected every second. i'm afraid it's directly database. @ first (start & conditions) wanna load things in memory. then, @ points, update values inside memory. once many seconds, update these values in database. could've been done nodejs suppose, it's using 1 core, , find little sad. not future proof if run cpu problems.

from performance point of view, approach may good, if performance of grouped sql request better sequence of individual requests.

the main inconvenient concerns robustness of application in case of crash. implement recovery mechanism may required.

concerning memory, it's difficult evaluate memory requirements observing available ram, because memory not freed immediatly : done @ system's demand when needed.

to compute used memory, evaluate size of objects , multiply count.

when processing user input, did evaluate average computation time and without database update ?


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -