title: Caching for poll?
body: <p>I'm building a poll widget using ASP.NET controls and Linq-to-Sql for a high traffic site. The widget is, actually, already built. But, it does not use caching yet.</p>
  
  <p>This poll can work in a multi-poll mode which means that each page load the control will hit the database to find any polls that the current user has not taken. There are also several database hits on the postback: a check to make sure the user has not taken the poll, a hit to write the result to the database, and a final series of hits to tally the results.</p>
  
  <p>Update, I've re-worded these questions:</p>
  
  <ol>
  <li><p>Would it be appropriate for a control such as a Poll to hit the database on every page hit? How would this performance scale up to a size of say 20,000 users. Assume the server has 2 servers, a load balancer, modern multiple core cpu, and 2 gig of ram.</p></li>
  <li><p>What type of caching for this scenario would you look to employ? Take into account that for example any number of people could take the poll over any interval of time and the total number of people who have taken the poll is needed to compute the results. More problematically, on every load the code must hit the database to find the polls that the user hasn't taken.</p></li>
  </ol>
  
  <p>I've some ideas but wanting to get some additional expert feedback. Thanks.</p>
  
  <p>Update:</p>
  
  <p>So, let us go over a scenario for caching. One could cache the Polls (the questions) but would still need to probably hit the database for the PollsTaken (the users responses). One possibility would be to create a shadow, writing both to an in-memory storage and to the database storage. </p>
  
  <p>One could use a refresh scheme to dump the cache when a user submits a successful poll (when it changes). A cookie could be used to prevent multiple-takes, although it would be susceptible to gaming.</p>
  
  <p>I want to go into and see more details on the scheme offered. For example, how you would use output caching, caching the linq-to-sql, etc. Not just generalities.</p>