Spring Boot - Docker Container - Synchronize Sections of Code between Containers? - spring

I have a Spring Boot app running in Docker in which I have a set of DB rows that, among which, I need to avert a race condition between instances of the app running in Docker containers. The app is stateless, but in this one area of code, I need to somehow synchronize between the Docker containers so that only one of them can perform this action at a time.
How can I synchronize between the containers so that only one at a time can perform this action?

Related

How can spring boot application instances be packaged in testcontainers

there are several instances of applications that interact with each other (microservices)
There are docker images of these spring boot apps
Is it possible to use these docker images in test container to deploy in tests and how is it possible to do this
There is no need to take into account the time to work and initialization of such tests, this is not the main thing in this situation.
Testcontainers offers GenericContainer which allow you to use images in the registry. For example, let's say you have a image for your service called myorganization/greetings-service:2.0.0 which listen request in the port 8080. Then you can use:
GenericContainer container = new GenericContainer("myorganization/greetings-service:2.0.0")
.withExposedPort(8080)
.waitingFor(Wait.forHttp("/"));
and later you can get the host and port using container.getHost() and container.getMappedPort(8080).
Hope this can help you

From an Application Server to Spring Boot - How Tos for Performance Tuning

Currently we have Java applications deployed in an Application server (Websphere to be exact). To fix common performance and memory related problems we encounter, we do tweakings like:
Adjust the thread pool setting - to prevent waiting threads.
Adjust the application server's garbage collection behavior.
Now, there is a plan to move them to containers (via Docker and using Spring Boot). So essentially they would be converted to Spring boot apps running on Docker containers. Now my question is, what is the equivalent of doing #1 and #2 in this kind of setup? is there still a way to adjust thread pool and garbage collection? or is it a different way now? or this shouldn't be an issue because docker swarm can manage all this and scale?
Edit: for the meantime, docker swarm will be used for managing containers. Kubernetes is still not in the picture.

EC2 check in Auto Scaling group

I have an ASG with min=2, max=4 configuration. In the boot up script of each EC2, I have a series of yum install and starting of 2 spring boot files. Now, when th e load increases and ASG spins up a new EC2 instance, it will perform all these in the boot up script.
Could anybody suggest a good method to validate whether all these yum installs have been successful and also whether the 2 spring boot files are running currently. If there is any problem with these, I dont want the EC2 instance to be attached to ELB.
I used cfn-signal to send information back to Cloudformation after performing my application and infrastructure level checks
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html

Sidecar doesn't support multiple instances of one NON-JVM app

I was able to register the single nodejs app instance using the netflix sidecar app successfully. Both nodejs and sidecar bridge app are running in Cloud foundry.
Result:
SAMPLE-NODEJS n/a (1) (1) UP (1)
When i scale the nodeJS app to 3 instances, could not see the scaled instances in Eureka service registry. It still shows 1 instance.
Can some one help me to do this....
I want to register all the instances of Nodejs app with Eureka service registry with Sidecar bridge app.
Pls.. help.
Regards
Purandhar
Sidecar, like the eureka java client is built to register only one application with the eureka server at a time. It is not a eureka proxy for multiple applications. I built a proof of concept proxy that will do what you want.
This happens because it's not your node application, which is registering to eureka, but your sidecar, which still runs in one instance.
simple solution
you scale your sidecars with your node apps. This is quite straight forward, in particular when using container based deployment. You just can craft a docker container starting both, a node instance and a sidecar.
load balancing
you can extend your sidecar application to load balance traffic to your sidecars. Then your node apps will still be shown as a single instance, but still have load balancing to scaled node instances

Programmatic method of starting xd-admin and xd-container in spring XD

In a distributed setup, how do I programatically start containers?
More specifically, does there exist any API similar to deploying and undeploying streams for setting up and tearing down containers?
There is currently no way to do this via an API. Containers are only known to the cluster after they are started. Upon initialization, the container registers itself with ZooKeeper. Running a container requires XD to be installed on that host which is currently a manual process: download,unzip,configure, as is starting the container. Some automation of operations will likely be provided in a future release.

Resources