Questions tagged [concurrency]

Concurrency is a property of systems in which several processes are executing at the same time.

Filter by
Sorted by
Tagged with
0 votes
1 answer
49 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
98 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
150 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
446 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
414 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
148 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
252 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
786 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 ...
3 votes
5 answers
1k 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 ...
1 vote
2 answers
77 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 ...
2 votes
2 answers
91 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 ...
83 votes
1 answer
23k views

Is there a difference between fibers, coroutines and green threads and if that is so what is it?

Today I was reading several articles on the Internet about fibers, coroutines and green threads, and it seems like these concepts have very much in common, but there are slight differences, especially ...
0 votes
0 answers
36 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 ...
1 vote
4 answers
2k 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 ...
5 votes
3 answers
1k 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
112 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
406 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
485 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 ...
0 votes
1 answer
498 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
130 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 ...
11 votes
1 answer
741 views

Concurrent fault-safe data structure

I am building an application that aims to process ~10M data items per second. Each item is exactly 42 bytes small (including a sorting key) which means the total data rate will not be big 420 MB/s. ...
0 votes
1 answer
1k views

Best Way To Take multiple TCP Connections, Read the Incoming Data, and send that Data back into the Main Thread in Golang?

I want to take data from my goroutines and add them back to the main thread/goroutine. Problem is that I need the goroutines to stay open because data can come through the connection at any time in ...
0 votes
1 answer
186 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 ...
6 votes
8 answers
3k views

When should I use parallelism? [closed]

After asking this question, I got to realize that parallelism may not always be good. So far I can see that parallelism (under c#) is A little complicated code-wise Will probably insert some ...
0 votes
0 answers
770 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 ...
1 vote
6 answers
1k views

Programming language with native concurrency support for large graphs?

I'm currently looking for a new programming language to learn (currently working through some C++, know some C and Python), specifically one that has built-in concurrency support? I want to try to ...
0 votes
1 answer
203 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 ...
3 votes
1 answer
304 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 ...
0 votes
1 answer
677 views

Modbus over TCP concurrency pattern

I'm trying to learn about MODBUS as a free-time project. It is a long standing desire to write my own driver in Golang. That being said, I'm now trying to design the concurrency model for device ...
1 vote
1 answer
419 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 ...
-4 votes
2 answers
135 views

Does server farm change the design of the server program?

In The Linux Programming Interface Sec 60.4, it talks about design a server that handles multiple requests using multiple processes or threads, or pools of processes or threads. Then it discusses ...
6 votes
1 answer
843 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
182 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
108 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
28 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 votes
1 answer
143 views

How state updates to existing instances/sessions are generally done?

This is a very broad question, but maybe someone has a worthwhile response. There is a general synchronization issue that often has to be solved, but always seems to be difficult. Here's an example: ...
0 votes
0 answers
189 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 ...
19 votes
3 answers
4k 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 ...
-1 votes
3 answers
482 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 ...
6 votes
1 answer
2k views

How does an product order payment works during a race condition?

This is a pretty generalized question which I am asking. Scenario 1 I have a product 'Pen' which has a quantity of 1. Now 2 users a and b has come to buy the product.User 'a' clicked on buy now and ...
4 votes
4 answers
3k 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 ...
32 votes
3 answers
64k views

UML Diagrams of Multi-Threaded Applications

For single-threaded applications I like to use class diagrams to get an overview of the architecture of that application. This type of diagram, however, hasn’t been very helpful when trying to ...
4 votes
3 answers
1k views

Do critical section and atomicity imply each other?

Is it correct that In concurrent programming, a critical section is a sequence of statements which can't be executed by more than one processes/threads at the same time. Atomicity (as "A" ...
-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
383 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
5 answers
2k 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 ...
-4 votes
1 answer
288 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
636 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 ...
1 vote
2 answers
2k 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
114 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
2 3 4 5
8