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 3962302
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:04:49+00:00 2026-05-20T03:04:49+00:00

Scenario: There exists ‘n’ teams who each work on their virtual ‘wall’ (like facebook’s

  • 0

Scenario: There exists ‘n’ teams who each work on their virtual ‘wall’ (like facebook’s wall). Each team sees only their own wall and the posts on it. The posts can be edited by the author of the post or another team member (if so configured. Assuming this is indeed the case since it’s a must have).

Design/technology decisions: RESTful web-app using Restlet+ Glassfish/Java + Mysql (EDIT: Using Apache DBUtils for DB access. No ORM – seemed an overkill)

Question: Multiple teams log on T1, T2 and T3 (say) each with some number of members. There is concurrency at the team-level data access, but not across teams – i.e., different teams access disjoint data sets. To optimize frequent read/writes from/to the DB we are considering a TeamGateway that controls access to DB for handling concurrency. The web-server would cache the data retrieved by the teams to speed up reads (and also to help updating the list of wall posts)

  • Q1: Is this (TableGateway per team + cache) even required? If not how do you suggest it be handled?
  • Q2: If so, does the TableGateway (for each team) need to be coded as thread safe (synchronized method)?? Let’s say we have a class/registry TableGatewayFinder with a static method that returns the TableGateway to use for that particular team (using a hashmap).

If 6 people from each of T1 – T3 log on then would ONLY 3 TableGateways be created and would it help catch concurrent writes (simple timestamp comparison before committing or a “conflict-flagged” append) and effectively manage the caching (We plan on having identity maps for the entities – there are 4-5 different entities that need to be tracked. 4 entities for a composition hierarchy and another one is associated to each of the 4)?

How would one unit test the gateway (TDD based or after the fact)?

Thanks in advance!

  • 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-05-20T03:04:49+00:00Added an answer on May 20, 2026 at 3:04 am

    If you just write to the DB or to a cache solution on top the DB (e.g. Spring+Hibernate+EhCache etc.), you don’t need to worry about corrupting your tables etc. I.e. no concurrency issue from a low-level point of view.

    If you want to write a cache yourself and deal with concurrency issues yourself, then that would involve some effort. If you shard your cache and have a “global lock” (i.e. synchronized on a common mutex) per partition, and acquire this lock for any access then that would work, while it’s not the most performant way to do it. But doing something else than a global lock would involve quite a lot of work.

    While this is trivial, not sure why you’d want to use a identity hash map… I can’t think of any particular reason you want to do that (if you are thinking about performance, then performance of a normal hash map would be the last thing you need to be worried about in this situation!).

    If your entities are articles, then you probably have another form of concurrency issue. Like the one that is solved by version controlling software like SVN, Mercurial etc. I.e. if you don’t put merging capability to your app., it becomes an annoyance if somebody edits somebody’s article only to find that somebody else has “committed” another edit before you etc. Whether you need to add such capability would depend on the use case.

    As for testing your app. for concurrency, unit testing is not bad. By writing concurrent unit-tests, it is much more easy to catch concurrency bugs. Writing concurrent tests is very tough, so I recommend that you go through good books like “Java Concurrency in Practice” before writing them. Better catch your concurrency bugs before integration testing when it becomes hard to guess what the hell is going on!

    UPDATE:
    @Nupul: That’s a difficult question to answer. However,if you just have 18 humans typing stuff, my bet is writing every time to the DB would be just fine.

    If you don’t store any state elsewhere (i.e. only in the DB), you should get rid of any unnecessary mutex (and you should not store any state anywhere else than the DB unless you have very good reason to do so in your situation IMO).

    It’s easy to make a mistake and acquire a mutex while doing something like a network operation and hence cause extreme usability issues (e.g. app does not respond for many seconds etc.). And it’s also easy to have nasty concurrency bugs like thread dead-locks etc.

    So my recommendation would be to keep your app. stateless and just write to the DB every time. Should you find any performance issues due to DB access, then turning to cache solutions like EhCache would be the best bet.

    Unless you want to learn from the project or have to deliver an app. with extreme performance requirement, I don’t think writing your own cache layer will be justified.

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

Sidebar

Related Questions

Let us take this example scenario: There exists a really complex function that involves
I have a scenario in which there exists a LINQ resultset; I used the
Consider the following scenario: There exists a globally accessible variable F . Thread A
Scenario: There is a website with 700-900 concurrent unique visitors at any given time.
scenario : there is some pages [ example home ,about us ,contact us etc]
Scenario : There is this online questionaire that will be filled in by various
I am trying to build a service/API. In my scenario there will be a
Scenario: If there is an array of integers and I want to get array
The scenario is there are two Android phones A and B. Phone A has
I have a ASP.NET MVC 3 app with a common scenario where there is

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.