I have seen a number of tests where a JVM has 10K threads. However, what happens if you go beyond this?
My recommendation is to consider having more servers once your total reaches 10K. You can get a decent server for $2K and a powerful one for $10K.
Creating threads gets slower
The time it takes to create a thread increases as you create more thread. For the 32-bit JVM, the stack size appears to limit the number of threads you can create. This may be due to the limited address space. In any case, the memory used by each thread's stack add up. If you have a stack of 128KB and you have 20K threads it will use 2.5 GB of virtual memory.
Bitness
Stack Size
Max threads
32-bit
64K
32,073
32-bit
128K
20,549
32-bit
256K
11,216
64-bit
64K
stack too small
64-bit
128K
32,072
64-bit
512K
32,072
Note: in the last case, the thread stacks total 16 GB of virtual memory.
I wrote an article on low latency microservices almost five years ago now. Chronicle Software has worked with a number of tier-one investment banks to implement and support those systems. What has changed in that time and what lessons have we learnt? Read this article and learn what we learned after five years of developing and supporting low latency microservices. Separation of Concerns Give Better Testability Microservices repeatedly demonstrated that testing and debugging business components were much easier with simple, stand-alone components with clear contracts between microservices. Unit tests were still used to start with. However, in 2017 we moved almost entirely to behavior-driven development of microservices. Unit tests are still used for lower-level libraries and utilities. As our microservices are all based on Kappa Architecture , all our behaviour driven tests are modeled as a series of events in and out of the service. An input test might look like this --- oms : O
There are things you can do in Java you rarely see, generally because there is no use for it. However, there are some unusual things in Java that could be surprisingly useful. Chronicle Software uses a number of different usual patterns in it’s low-level libraries most developers wouldn’t generally come across. One of them is a class that extends Throwable but isn’t an Error or an Exception. StackTrace Extends Throwable package net.openhft.chronicle.core; /** * Throwable created purely for the purposes of reporting a stack trace. * This is not an Error or an Exception and is not expected to be thrown or caught. */ public class StackTrace extends Throwable { public StackTrace() { this ( "stack trace" ); } public StackTrace(String message) { this (message, null ); } public StackTrace(String message, Throwable cause) { super (message + " on " + Thread. currentThread ().getName(), cause); } public static StackTrace forThread(Thread t) {
A Unique Identifier can be very useful for tracing. Those ids are even more useful when they contain a high-resolution timestamp. Not only do they record the time of an event, but if unique can help trace events as they pass through the system. Such unique timestamps however can be expensive depending on how they are implemented. This post explores a lightweight means of producing a unique, monotonically increasing system-wide nano-second resolution timestamp available in our open-source library. Uses for Unique Identifiers Unique identifiers can be useful to associate with a piece of information so that information can be referred to later unambiguously. This could be an event, a request, an order id, or a customer id. They can naturally be used as a primary key in a database or key/value store to retrieve that information later. One of the challenges of generating these identifiers is avoiding creating duplicates while not having an increasing cost. You could record every identi
Comments
Post a Comment