Questions tagged [concurrency]
Concurrency is a property of systems in which several processes are executing at the same time.
379 questions
0
votes
3
answers
327
views
Transaction management with one connection
We have a desktop application written in Java that communicates with a DB. We support Oracle and Postgres. For the purpose of this question, let's focus on Postgres
Our app uses one connection for all ...
-2
votes
3
answers
276
views
How to present serious flaws in third-party software to non-technical users
We have third party software being tested. Our software has to interface with this, hence my involvement. There are some things I consider serious technical flaws. I'd like to communicate these things ...
4
votes
3
answers
2k
views
Not await an asynchronous method because it is like an endless loop - good practice?
I inherited a piece of software. This program is connected to an external hardware, which is a measurement device. Every 100 milliseconds, a value is read from this device and displayed to the user. ...
2
votes
4
answers
317
views
Ensure concurrent processing based on a message key
I've been wondering about the following: Say you have an async message/task and you want that message only processed one at the time. for example: Only process one order for each customer at the time. ...
0
votes
1
answer
399
views
Using a thread-locking service as a singleton dependency in .NET
So I'm working on the Web API for my website and certain API calls need to be performed with thread safety in the application's runtime. I have created a locking service which uses a semaphore for ...
0
votes
1
answer
710
views
C++ memory visibility, passing data between threads
I use code like this and it seems to work fine:
void addActions(const vector<zero_arity_function>& _actions)
{
actionsMutex.lock();
for (auto entry : _actions) {
...
1
vote
2
answers
237
views
Ensuring partial order of concurrent operations
I have the following operations:
User submits event
We store event in a queue
Wait for events and store them in db for redundancy
Wait for events and process them
Remove events from queue and db
For ...
2
votes
2
answers
200
views
How to document a concurrent communication protocol for less theoretical people
We are developing a multi-user web-based application, where the users can join a "room" and a complicated handshake has to be set up between them, to be able to use a library on each ...
1
vote
3
answers
490
views
What algorithm can I use in order to not let there be two rows with same "mobile number" in database?
The issue that I'm facing is on a banking app. There are two ways to register for internet banking.
A) Self Register
B) Ask for bank to register via their GUI panel backend.
Consider this scenario:
...
2
votes
3
answers
638
views
Are there downsides of two TCP connections for bidirectional communication?
I have a server which maintains some shares state.
The clients can send some requests and get an answer from the server.
Sometimes the server needs to give some information to the client ...
1
vote
1
answer
217
views
High Throughput Concurrent Map Access and Periodic Updates Causing Contention and Latency Spikes
I am working on a Go application where two concurrent maps, products and productCatalog, are accessed by numerous threads in live traffic to retrieve data at high throughput. These maps are populated ...
1
vote
2
answers
695
views
Handling simultaneous duplicate expensive read-only HTTP requests
(updated)
We have a read-only REST endpoint that performs a somewhat “expensive“ but transient request. Without client needing to poll, we need a mechanism for the server to avoid unnecessary ...
4
votes
2
answers
1k
views
How can a web browser simultaneously run more videos than the number of CPU cores?
I've been learning about threads and processes and I understand that threads allow you to write concurrent code: where executing threads switch very quickly from one to another, giving the impression ...
1
vote
2
answers
95
views
Phantom read race condition keeping RDBMS in sync with external storage
Here's an interesting scenario, consider a cache with many buckets, and resources that can be shared between buckets:
Bucket
Highest to lowest priority
Foo
A, B, C, D
Bar
B, C, D
Baz
A
In the example ...
2
votes
2
answers
159
views
Should a mobile app keep an 'outdated' version of the data and refresh it from database or always fetch from database?
I'm building a mobile, in which the user is able to create,modify and delete entries in a database. There are multiple screen where some of the entries are displayed: (here are some examples, not ...
4
votes
5
answers
2k
views
Where to control optimistic concurrency in a domain-driven design (DDD) application?
I am thinking how to develop an application in a DDD way, and now I am thinking about the concurrency part.
In some examples I have seen that in the domain classes are injected with dependency ...
0
votes
0
answers
86
views
Handling competing requests for the same "id" in different Kubernetes PODs
I have the following problem, I am implementing a delivery management service and a single order can be competed between N deliveryboys, this service is being executed on Kubernetes with 5 PODs of ...
6
votes
3
answers
3k
views
Checking if a file exists before writing. Always avoid, or sensible with the right use case?
There are few reliable absolutes in this world. One I have relied on is the idea that checking if a file exists before doing something with it just creates an unwanted race condition. Meaning between ...
0
votes
2
answers
257
views
How do I guarantee ordered processing of occurring events in concurrent environment?
I have a Kafka topic providing events of the following type: id(hash):[ADD|REMOVE].
These events may be generated at a high rate and are idempotent, i.e. getting 123:ADD one time and ten times in a ...
7
votes
1
answer
540
views
Can functional programming languages have deadlock conditions?
I am reading through "Clean Architecture: A Craftsman's Guide to Software Structure and Design" and it says that:
All race conditions, deadlock conditions, and concurrent update problems are ...
1
vote
1
answer
664
views
Is DynamoDB optimistic locking with one version attribute for each field in an item a valid design pattern?
It's common to implement optimistic concurrency control in DynamoDB by giving each item in the database a top-level "version" attribute and only allowing an update of an item to succeed if ...
1
vote
1
answer
873
views
In DDD, concurrency belongs to application layer?
In DDD, the model has to implement only the bussiness logic, and it has not the responsability about another things, like persistance.
So I was thinking that perhaps is in the application layer a good ...
0
votes
0
answers
188
views
How to generate idempotency token for remote cache
We are using a client library over Memcache.
This library has a lot of logic for Memcache client and is indispensable in current form.
One of the API of the library is put which internally just uses ...
0
votes
1
answer
475
views
SQL databases - what will happen if dozen of users edit the same record at the same time?
I know that we have the functionality to lock records or setting isolation level, but this is not my question.
By default if dozen/hundred of users edit the same record at the exact same time what ...
0
votes
0
answers
1k
views
How does Spring boot and Postgres handle the concurrent updates?
I want to understand how does Spring Boot and Postgresql DB handle the concurrent requests for updating a value in DB. Consider this example of facebook likes, if there are multiple instances of ...
0
votes
1
answer
332
views
Design of A Multithreaded Simulator
When designing my simulator, I have gotten stuck on 2 main design choices.
The simulator can be described as having X number of nodes (between 50 - 2000) that each need to independently do some ...
1
vote
4
answers
5k
views
What are the use cases for SQL row version columns?
Docs and blog posts describe what row version columns do, but rarely delve into the decision process of when it's appropriate to use them. I suspect that many developers just add them to every table ...
3
votes
1
answer
353
views
Structured concurrency and GUI applications
Intro
Structured concurrency is a relatively recent concept for structuring concurrent programs. It has implementations in for example Python, Java and Swift.
Examples of structured concurrency often ...
2
votes
1
answer
568
views
Does "green threads" necessarily imply cooperative multitasking?
Java used to have green threads, i.e., implemented inside the VM.
The description of Python Eventlets says
"Eventlet is built around the concept of green threads (i.e. coroutines...).... Green ...
6
votes
1
answer
1k
views
Specify that a method needs a mutex held when calling
Current situation
Right now I have a method like
Data lookupData(Key id)
{
std::lock_guard<std::mutex> lock(m_mutex);
auto it = m_dict.find(id);
if(it == m_dict.end())
{
...
0
votes
3
answers
218
views
Critical section with two different "rights of way" [closed]
In C#, how do I handle critical section with two different "rights of way"?
Theoretical use case: imagine a swimming pool (the resource). Many individual swimmers (worker threads A, B, C, ...
0
votes
2
answers
119
views
What is the (lowercase 't') true definition of "support" (to a computer scientist)? [closed]
tl;dr An audacious claim by a classmate caused me to question the definition of the word "support" (verb) in the context of computer science. Is it analogous to standard definitions where a ...
0
votes
0
answers
38
views
Is there a way to add impending state changes to a queue on a node server, and is it necessary?
I'm writing an express/socket.io-powered game server for a web game. I have a central map of game state objects, each representing an ongoing match, like so:
// map of gameId -> game (primary ...
1
vote
0
answers
332
views
Managing concurrent TCP connections with Go, Docker and Kubernetes
I need to consume several APIs concurrently. In order to do that I decided to containerize each API client code and manage them using Kubernetes. Some of those APIs need to be "walked". They ...
21
votes
3
answers
5k
views
How do you test and demonstrate that you have properly prevented a race condition? [duplicate]
Suppose I'm building a web application using Django. Some of the views need to touch multiple database tables or rows, and there is some kind of state consistency that I need to ensure among the ...
4
votes
4
answers
4k
views
What will you do if multiple users access your application at the same time?
I'm an experienced Software Engineer but very weak in concurrency because of no prior experience in that. I've been interviewing with several companies in which I was asked similar kind of questions ...
-1
votes
1
answer
2k
views
Locking a DB table and waiting for writing/reading it from a web application
I'm working on a web application using Spring (Java and JPA + Hibernate) and I was wondering if there is a way of locking a MYSQL table and then when another web service (or even another thread from ...
4
votes
1
answer
423
views
Could the async keyword be eliminated in a new programming language?
This post implies that the creators of Rust had to add the "async" keyword to make the async/await functionality backward compatible.
Why do we need the async keyword?
In a new language, ...
-4
votes
1
answer
450
views
Does native async implementation in languages like Python and C# Solve the "Free Lunch is Over" problem? [closed]
A while ago Herb Sutter wrote The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software which I basically interpret to mean that, in order to improve performance, software engineers ...
1
vote
3
answers
1k
views
How do I make sure a task run only once in a dockerized environment?
I have a task that I need to make sure it only runs once in my dockerized environment (managed by k8s), running the post-upgrade script is one example.
Because each dockerized app can run the task and ...
4
votes
5
answers
3k
views
How can you ensure order of execution in concurrent tasks?
Here is what I am specifically doing:
I have a thread-safe queue
One 'write' thread constantly writes to the queue with data that comes from another service
Multiple 'read' threads take from the ...
1
vote
2
answers
3k
views
How to avoid race condition in reservation system [duplicate]
I'm trying to design a system to buy mangoes (not really mangoes, but it's a good proxy). One mango is the same as the other. These are very high-in-demand mangoes; quite possible many people at once ...
3
votes
1
answer
199
views
Handling deployment of a stateful service?
For fun, I'm developing a multi-player card game. I plan to run it on a single cheap VPS, so deployment would have to kill the process and re-start it with the new code. There is no Load Balancer. I'm ...
-1
votes
1
answer
156
views
Implementation of concurrent purchase for unique items
I am building an API for webshop. I need to implement following scenario:
There are x (let's say 500) digital items, which will have same price (let's say each item costs 10$), but unique serial ...
0
votes
1
answer
215
views
How to deal with massively concurrent events?
I got the following interview question:
Say the company has this event, where we will create a button on a website and only the first ten clicks will be accepted and win a prize. Assume that there a ...
0
votes
2
answers
914
views
Concurrent network I/O
Correct me if I am wrong, but regarding file I/O and concurrency, I understand that it makes no sense to read 2 files concurrently, since the data bus cannot be used simultaneously. This means that ...
0
votes
2
answers
1k
views
Approaches of splitting the same type of work among multiple threads in C++
I have a reinforcement learning project.
For this I created a vectorized environment in C++, which is a handler for multiple instances of a simple game.
It is highly parallelizable. Each worker can ...
-3
votes
1
answer
432
views
Is Go's concurrency model suitable for distributed systems and for microservices?
In Programming Distributed Computing Systems:
7.3.4 Distribution
Distributed computing is inherently concurrent. However, distribution
aspects go far beyond concurrency. Of particular importance from ...
26
votes
4
answers
6k
views
Do compilers optimise in concurrency?
Presuming that I have written some sequential code where it can be broken down into multiple isolated tasks, it seems it might be efficient for concurrency to be introduced.
For example
print(...
-1
votes
3
answers
652
views
Is it possible to solve this synchronization problem using mutex and conditional variables?
I am trying to solve this synchronization problem in C to practice for my lectures of Operating Systems where we use POSIX and Linux. I've been trying for days to find an approach to this problem with ...