需要在Web场中的页面刷新之间保存ASP.NET中的数据块,而不使用inprpc或状态服务器

时间:2022-02-02 03:54:39

I have an asp.net application running in a server farm. So In-proc sessions are out. There's no state server. There's a sql server database (can't be used for state server). There's no forcing same web server serving capabilities so no guarantee which web server will serve next page.

我有一个在服务器场中运行的asp.net应用程序。所以进程内会议结束了。没有状态服务器。有一个sql server数据库(不能用于状态服务器)。没有强制相同的Web服务器服务功能,因此无法保证哪个Web服务器将在下一页提供服务。

I need to save a block of data (big object state) between pages. I don't want to use viewstate because data could be large and don't want it to go across the wire. I could use the database to save the data and use the record id across the wire in a viewstate and retrieve the data for the next page.

我需要在页面之间保存一个数据块(大对象状态)。我不想使用viewstate,因为数据可能很大,并且不希望它跨越网络。我可以使用数据库保存数据并在视图状态中使用线路上的记录ID,并检索下一页的数据。

Are there better solutions?

有更好的解决方案吗?

3 个解决方案

#1


1  

Well, I guess you've ruled out most options already. And assuming you cannot install other services, two other possibilities come to mind:

好吧,我猜你已经排除了大多数选择。假设您无法安装其他服务,我会想到另外两种可能性:

  1. Use a writable file share to store the data.
  2. 使用可写文件共享来存储数据。
  3. Allow the individual web servers to communicate with each other. For instance, make the machine's IP or name part of the generated unique identifier; that way, if you reach a different server on postback, that server can call the original server for its data. Mind you: if one server goes down (or the ASP.NET process is recycled), all it's data is lost.* That shouldn't happen that often, I hope, regardless of this subject.
  4. 允许各个Web服务器相互通信。例如,使机器的IP或名称成为生成的唯一标识符的一部分;这样,如果您在回发时到达不同的服务器,该服务器可以调用原始服务器获取其数据。请注意:如果一个服务器出现故障(或者ASP.NET进程被回收),那么它的所有数据都将丢失。*我希望,不管这个主题如何,这都不应该发生。

As in the SQL Server version, don't forget to clean up your data somehow; option 1 is pretty similar to SQL Server in that regard, but in case of SQL Server it could simply be a centralized cleanup job, in the file share case the question becomes: which server is the center?

与SQL Server版本一样,不要忘记以某种方式清理数据;在这方面,选项1与SQL Server非常相似,但在SQL Server的情况下它可能只是一个集中的清理工作,在文件共享的情况下问题变成:哪个服务器是中心?

*) You could, of course, try to spawn a secondary process from ASP.NET. The problem here becomes: what if that process has problems? It's not manageable for your sysadmins by default, unless you make it manageable.

*)当然,您可以尝试从ASP.NET生成辅助进程。这里的问题变成:如果那个过程有问题怎么办?默认情况下,您的系统管理员无法管理,除非您将其设置为可管理的。

#2


4  

I could use the database to save the data and use the record id across the wire in a viewstate and retrieve the data for the next page.

我可以使用数据库保存数据并在视图状态中使用线路上的记录ID,并检索下一页的数据。

You've eliminated every other option.

你已经淘汰了其他所有选项。

#3


0  

I'm not sure if I read right, but can you not use the database to store the asp.net session?

我不确定我是否正确阅读,但您是否可以使用数据库来存储asp.net会话?

<sessionState
      mode="SQLServer"
      sqlConnectionString="somedb"
      cookieless="AutoDetect"
      timeout="20"
    />

You could also use some sort of distributed caching solution like memcached(http://www.danga.com/memcached/ and that could persist the data between postbacks.

您还可以使用某种分布式缓存解决方案,如memcached(http://www.danga.com/memcached/,这可以在回发之间保留数据。

#1


1  

Well, I guess you've ruled out most options already. And assuming you cannot install other services, two other possibilities come to mind:

好吧,我猜你已经排除了大多数选择。假设您无法安装其他服务,我会想到另外两种可能性:

  1. Use a writable file share to store the data.
  2. 使用可写文件共享来存储数据。
  3. Allow the individual web servers to communicate with each other. For instance, make the machine's IP or name part of the generated unique identifier; that way, if you reach a different server on postback, that server can call the original server for its data. Mind you: if one server goes down (or the ASP.NET process is recycled), all it's data is lost.* That shouldn't happen that often, I hope, regardless of this subject.
  4. 允许各个Web服务器相互通信。例如,使机器的IP或名称成为生成的唯一标识符的一部分;这样,如果您在回发时到达不同的服务器,该服务器可以调用原始服务器获取其数据。请注意:如果一个服务器出现故障(或者ASP.NET进程被回收),那么它的所有数据都将丢失。*我希望,不管这个主题如何,这都不应该发生。

As in the SQL Server version, don't forget to clean up your data somehow; option 1 is pretty similar to SQL Server in that regard, but in case of SQL Server it could simply be a centralized cleanup job, in the file share case the question becomes: which server is the center?

与SQL Server版本一样,不要忘记以某种方式清理数据;在这方面,选项1与SQL Server非常相似,但在SQL Server的情况下它可能只是一个集中的清理工作,在文件共享的情况下问题变成:哪个服务器是中心?

*) You could, of course, try to spawn a secondary process from ASP.NET. The problem here becomes: what if that process has problems? It's not manageable for your sysadmins by default, unless you make it manageable.

*)当然,您可以尝试从ASP.NET生成辅助进程。这里的问题变成:如果那个过程有问题怎么办?默认情况下,您的系统管理员无法管理,除非您将其设置为可管理的。

#2


4  

I could use the database to save the data and use the record id across the wire in a viewstate and retrieve the data for the next page.

我可以使用数据库保存数据并在视图状态中使用线路上的记录ID,并检索下一页的数据。

You've eliminated every other option.

你已经淘汰了其他所有选项。

#3


0  

I'm not sure if I read right, but can you not use the database to store the asp.net session?

我不确定我是否正确阅读,但您是否可以使用数据库来存储asp.net会话?

<sessionState
      mode="SQLServer"
      sqlConnectionString="somedb"
      cookieless="AutoDetect"
      timeout="20"
    />

You could also use some sort of distributed caching solution like memcached(http://www.danga.com/memcached/ and that could persist the data between postbacks.

您还可以使用某种分布式缓存解决方案,如memcached(http://www.danga.com/memcached/,这可以在回发之间保留数据。