Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:04:59+00:00 2026-06-13T09:04:59+00:00

There are a lot of posts saying that SingleInstance is a bad design. But

  • 0

There are a lot of posts saying that SingleInstance is a bad design. But I think it is the best choice in my situation.
In my service I have to return a list of currently logged-in users (with additional data). This list is identical for all clients. I want to retrieve this list from database every 5 seconds (for example) and return a copy of it to the client, when needed.
If I use PerCall instancing mode, I will retrieve this list from database every single time. This list is supposed to contain ~200-500 records, but can grow up to 10 000 in the future. Every record is complex and contains about 10 fields.

So what about performance? Is it better to use “bad design” and get list once or to use “good approach” and get list from database on every call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:05:00+00:00Added an answer on June 13, 2026 at 9:05 am

    So what about performance? Is it better to use “bad design” and get
    list once or to use “good approach” and get list from database on
    every call?

    Performance and good design are NOT mutually exclusive. The problem with using a single instance is that it can only service a single request at a time. So all other requests are waiting on it to finish doing it’s thing.

    Alternatively you could just leverage a caching layer to hold the results of your query instead of coupling that to your service.

    Then your code might look something like this:

    public IEnumerable<BigDataRecord> GetBigExpensiveQuery(){
    
       //Double checked locking pattern is necessary to prevent
       // filling the cache multiple times in a multi-threaded
       // environment
       if(Cache["BigQuery"] == null){
          lock(_bigQueryLock){
             if(Cache["BigQuery"] == null){
                var data = DoBigQuery();
                Cache.AddCacheItem(data, TimeSpan.FromSeconds(5));
             }
          }
       }
    
       return Cache["BigQuery"];
    
    }
    

    Now you can have as many instances as you want all accessing the same Cache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are a lot of posts regarding parsing twitter json, but none that I
Although there are a lot of posts about .net config files, I believe that
I know there are a lot of posts related to this particular error but
I know there's a lot of posts with the same that problem. I just
I know that there are lot's of questons on this, but all seem to
First, let me begin by saying that I have done a lot of research
There is a lot of posts about nested Ajax problems, but I can't figure
There are a lot of similar posts but nothing quite fit my need. So
I know there are a lot of posts about this, but I cannot get
I know there are a lot of posts about git workflows, but I couldn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.