Reputation: 4524
As far as i know, static variables and methods are shared across different sessions. dose this sort of behavior may cause performance degradation, for example when different sessions are reading a static var or calling a static variable at the same time.
Upvotes: 1
Views: 416
Reputation: 59184
There's no usually performance penalty involved in multiple threads reading the same variable or calling the same method at the same time, as long as no other threads are writing to that variable.
And if one thread can write a variable that another thread is reading, then you have a concurrency control issue that you need to handle carefully.
Note, however, that there may be an exception to the above on specific kinds of hardware when a variable that one thread writes is adjacent in memory to a variable that other threads read. In this case they may be in the same "cache line" -- the unit of memory that is read from RAM and cached, and in that case there may be contention between the readers and writers, as the hardware can't tell that they aren't accessing the same location.
The googlable term for this is "false sharing".
Upvotes: 1
Reputation: 45319
Simply "using static variables across sessions" does not inherently have performance implications. There is, however, a cousin concern that you need to look at, instead.
The fields that you're reading from/writing to from multiple user sessions will be accessed concurrently. This means that you will need to make your objects thread-safe (that's going to be necessary if you are writing to these static fields). This is what can have direct performance implications.
Upvotes: 0