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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:58:40+00:00 2026-06-01T00:58:40+00:00

Here is the situation, I have 3 instances, one is a manager, for assigning

  • 0

Here is the situation, I have 3 instances, one is a manager, for assigning job, and two is worker, doing to job. Let say the user need to withdraw something, and workflow is like follow:

Request sent 
Manager assign job, depends on worker instance loading 
worker do the work (reduce the num in db) 
tell the manager instance job is finished!

All things work, but two instance may have two withdraw in same account, it may have some problems, to make a negative number…. So, it have some problems there. Well, you can say add an execute channel or queue or something that only execute one database’s write function….

But the problem is when I have more and more instance, only with one instance for writing, that may reduce the productivity, any recommends? Thanks.

  • 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-01T00:58:41+00:00Added an answer on June 1, 2026 at 12:58 am

    How do you do it?

    By carefully designing the operations to be atomic, and doing all of the relevant checks, accesses and updates as part of the atomic action.

    Now you mention that you have a database as part of the implementation technology. Assuming that it is a transactional database, you should be mapping each of these atomic operations to a transaction. So, to build on your description:

    1. Request received
    2. Manager assigns job to a worker
    3. Worker does the work of the withdrawal as follows:
      1. Start database transaction
      2. Check that account exists.
      3. Check that withdrawal > 0.
      4. Check that balance - withdrawal >= 0
      5. Update the database balance.
      6. Commit the transaction, or roll it back if there were errors.
    4. Worker reports outcome to Manager
    5. Manager responds to request.

    On the other hand, if there was no database involved, and you were simply updating in-memory objects, then you’d create an Account class that had a synchronized method for doing a withdrawal that did steps 3.3 through 3.5 of the above, and have the worker call the method with the relevant parameters.

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

Sidebar

Related Questions

Here's the situation: we have an Oracle database we need to connect to to
Here's the situation: We have some generic graphics code that we use for one
Here is my situation: I have one table that contains a list of drugs
Here's the situation I have a webpage which has one drop down called prefer.
I am curious how people are handling the following situation. Let's say we have
Here's the situation: I have a label's text set, immediately followed by a response.redirect()
Here is the situation: I have been called upon to work with InstallAnywhere 8,
Here is my situation: I have an application that use a configuration file. The
Here is the situation : we have to offer a customer with a web-based
here's the situation: I have a where in every cell all the area has

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.