How to Share Hash Table within 2 IIS server - iis-7

I have Created a .net core application with signal R, i had also configured Load balancer with it, now the case is i had 2 server, when my application start and user login, signal R create a hash table and store user id with signal R Id, now if there are 2 server then how other server knows about other servers hash table value, is there any better approach use for signal R when we use load balancer.
Thank you,

Related

ASP.Net MVC database first, database connections

I need help!
We have winforms app with existing large db (SQL), and I have started the project that aims to reproduce some of the logic on the web. For this purpose I decided to use Asp.Net MVC database first approach.
But! There are a lot of Views, Procedures and Functions in our db that based on connected user host_name()+host_id() (for example, filtering views by permissions or filling the temp tables for current user (connection)), but Web connection (with IIS) provides the same host_id() and host_name() for all it's connections, so I try to find approach that will allow me to recognize the connection (one user can have few connections) in SQL with the minimum db object changes.
Have any idea?
You can supply the value for HOST_NAME() from the client by including the WSID=newName in the connection string.
So in your application code, you'll have to obtain the connecting machine's hostname, then generate a connection string on the fly containing the WSID parameter, and pass that connection string to Entity Framework.

Session storage on a separate server

I use 3 server through "Amazon balancer". On each server installed 2 (asp.net) web application (website, mobile site). "Balancer-Amazan"- so constituted that every 3 hours produces load transfer between servers, all session will be crash and creating a new (the users logs off)
Advise the possible solutions to the problem.
Thanks in advance.
If you have SQL Server available you can store your session state in that:
HOW TO: Configure SQL Server to Store ASP.NET Session State
You could even implement your own if SQL Server is not available:
http://msdn.microsoft.com/en-us/library/ms178588.aspx
How to: Sample Session-State Store Provider
The only caveats are that you can only store serialisable objects in the store, i.e. you wouldn't, for example, be able to store a System.Xml.XmlDocument object without turning it's representation into something than can be serialised, i.e. a string representing the XML.
I wrote up another answer that may be useful/provide further reading:
ASP.NET Session size limitation

ASP.net sessions on 2-machines server

If we start to use 2 servers instead of one, with load balancing, is there a way to store sessions in memory, so we wouldn't need to change 50 webconfigs to set sessions are stored in database?
Obviously, 2 servers would be there if one fails, so storing sessions in memory would back things to beginning.
Thanks.
One option is to use a load balancer that supports "sticky sessions". What that means is that the load balancer will always forward requests with the same session id to the same server, so no session sharing is required.
If I understand your question correctly, then the answer is "No". If you are using the default inprocess session provider, then when you switch to using 2 machines, you will need to switch the session provider to some out of process (ie Sql Session provider or Memcached) session providers so that both machines can access the same session source. This means you will need to modify all the web.conf

ASP.net Session in SQL or cookie

I deployed an ASP.net web site to two servers and put them behind the load balanced environment. Now that problem is that the performance is really slow. Even for just simple button event, it takes long time to finish the simple button event. However, if I access the site separately (by its server’s address), performance is good. What our system engineer told me was that the application handles session state in process as if it runs on only one server, it could not handle clustering. So, he suggested that I should use the session object in the code to store the session in SQL server, or cookie.
I am currently using session variables to store the session.
I am kind of a new to ASP.net and I am not sure exactly what this mean and how I can accomplish this in my .net code (C#)?
Thanks.
Here is a good link to start you off: ASP.NET Session State
You would probably want to go with the Out of process mode where the servers all access 1 session process on a designated server, if speed is your top priority or SQL Server mode where all servers access 1 database if reliability is your top priority as with out of process mode if the process dies your session data is lost similar to how in-process session handling works.
No coding changes for storing session data would be needed, just the initial configuration of the environment and a web.config change.
First off, you need to configure sessionstate in your web.config for what you want to do. Here is a step by step tutorial on storing sessionstate in sql server. Hope it helps!
http://support.microsoft.com/kb/317604

ASP.NET: Is Session Object my acceptable solution for static variable?

I've read several threads about this topic and need some clarification on a few sentences I read in a book:
If you store your Session state in-process, your application is not scalable. The reason for this is that the Session object is stored on one particular server. Therefore storing Session state in-process will not work with a web farm.
What does "scalable" in the first sentence mean?
Does the third sentence means if my app resides on a shared web host, I shouldn't use Session["myData"] to store my stuff? If so, what should I use?
Thanks.
1:
Scalability in this sense:
the ability of a system, network, or process, to handle growing amounts of work in a graceful manner or its ability to be enlarged to accommodate that growth.[
2:
Use a session server or store sessions in SQL Server, which are described here.
ASP.NET can store all the combined Session information for an Application (the "Session State") in 3 possible places on the server-side (client cookies is also possible but that is a different story):
"InProc" (In Process) which means in memory on the IIS server attached to the asp.net worker process,
"StateServer" which is a separate process that can be accessed by multiple IIS servers but still stores the Session state in memory, and
"SQLServer" which stores the Session state in a SQL Server database.
1) The reason In-process is not scalable is if your needs exceed the capacity of a single IIS server, multiple servers can't use an In-process session state. If you have determined a shared hosting scenario will fulfill you needs, you don't need to worry about it.
2) When you store something in Session["Name"], ASP.net stores that data wherever the application is configured to store Session state. If you want to change where Session state is stored, all you need to do is configure your web.config file. If you are using a shared hosting environment, your IIS deployment is considered single server even though no doubt the actual servers are in a farm of some sort.
See: MSDN Session-State Modes

Resources