简体   繁体   中英

Store a File in session variable?

I have three questions here

  1. Can i Save a File in session?
  2. If so what will be the maximum size of the file?
  3. Does it affect the speed of site when number of concurrent users increases?
  1. Yes you can.
  2. There is no maximum size. Depend of your server memory.
  3. Storing large files will slow the performance of your server.

Consider using another way to store files for users. You can put them in a DB, related to the user identity.

  1. Yes you can.
  2. the limit is related to Server memory==> Limit= Number of Concurrent users * Size of Session. this should not exceed server virtual memory size.
  3. Yes and No... if you have limited server memory, it will affects overall server performance and so your website. try to minimize the session time out so its effect will be minimized.
  1. Yes you can save the file in session object. One possible way could be to serialize it and save.
  2. Maximum limit is your server memory.
  3. Yes it will slow down the site as your server memory is occupied by these Session variable. Try avoiding session variables as it impacts all the users.
  1. Yes
  2. I don't think there is a strict constraint on that, it rather depends on the total available memory at the server side
  3. Yes, definitely. The more memory your application consumes, the more likely is it will sooner or later need to use the virtual memory. And virtual memory is terribly slow comparing to physical memory. Multiply that by the number of concurrent sessions and most probably you get terrible overall performance of your application. One of the possible approaches is to use the SQL Session Provider that stores session data in the SQL Server. That slows down the entire app, however, the session data do not occupy physical/virtual memory anymore. The performance hit is then predictable and it doesn't depend much on the number of actual concurrent users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM