What timekeeping functions should I use if I want to profile the early boot process?
I want to see which drivers take too long to probe/attach/initialize and if there is a way to reduce that amount of time. There may even be earlier parts of boot which are too slow.
Kernel tracing can e.g. be done with ktr(4).
Another option is to use dtrace. Sample scripts for monitoring the kernel can be found in /usr/src/cddl/contrib/dtracetoolkit/Kernel/.
Related
Lets say I have 25 spring boot micro-services each of which starts with 1GB JVM in production. At any given time not all are in use and there is no instance when they are using the full 25GB memory at once. In reality many of them will sit idle 90% of the time but any of them might at some point get called and require up to 1GB memory.
In my development environment I would like to run all of them at once but only have 8GB memory. I don't need great performance but I need them all to run at the same time for the entire app to work. I would like to try to run all the applications within a single JVM with 6GB dedicated memory. That should be enough at any given time.
This seems like it would be a common issue as many companies are converting to cloud/microservices. 10 years ago we would have one monolithic app with single JVM (easy to run in dev environment). Now we have dozens of small apps which might not need a ton of memory but they each run in their own JVM so each has a good amount of overhead. This actually makes development more complex rather than simplifying. So Im trying to find a solution for our developers where they can run everything but not kill the memory on their machines.
The spring boot apps need to run without modification aside from
maybe local profiles. Otherwise developers would have to make tons of changes every time they pull the code from git
Each project needs to be able to configure a different port (application-local.properties setting)
for tomcat.
Each project needs its own classpath entries (for instance one might use version 1.0 of a jar and another might use version 2.0 and without separate classpaths one or the other would break)
I have been trying to follow this post but its not 100% what I want. I feel like a proper solution should respect the application.properties / application-local.properties file and use the port set inside the project rather than having to hardcode any configuration outside the project. Essentially his post is starting a separate thread for each microservice and attaching a separate classloader to each thread. Then calling SpringApplication.run and passing in the classname that would normally be used to start the microservice. I think this is maybe ignoring the auto configuration properties.
Any help would be greatly appreciated!
You can manage how much resources your applications are consuming with docker. One spring boot application should be one docker container. You can at runtime change how much resources(in your case memory) container use. Take a look at this
article on how to at runtime change resource allocation in docker. Also, with kubernetes is possible to define minimum and maximum resources that your application needs.
I noticed that there are only a few camel extensions available to use in native mode. I am wondering if it's still possible to use the other camel components if you don't compile to native? And if, is it usefull to go that way, or should we for example stick to spring boot?
Note that all Camel extensions might not need a Quarkus one. Basically, a Quarkus extension is needed if we need to tune the Camel extension for GraalVM (add reflection declarations for instance). The interesting thing is that you can even do the work manually to make your Camel extension work in GraalVM mode and then report back so that we create a proper extension for all future use.
In JVM mode, all Camel extensions should work flawlessly. If you encounter an issue, please open a GitHub issue and we will take a look at it.
About if using Quarkus in JVM mode is worth it, I'm obviously partial but I think the Quarkus approach is beneficial even in JVM mode. You still have some of the benefits of better boot time and reduced memory usage. Obviously, depending on your application, they might not be important to you.
We want to add a tracer id(MDC) across multiple REST services as part of the logging, so we can follow all calls in our log based on the id.
Is Spring sleuth suitable for using as distributed logging framework with 100% sampling all the time, or are we misusing it?
We are concerned about the overhead with 100% sampling
Yes you can. You can modify the percentage at runtime if necessary. We wouldn't be building a tool that is not suitable for distributed systems.
I have a web service written in scala and built on top of twitter finagle RPC system. Now we are hitting some performance issues. We have external API components and database layer.
I am planning of installing Zipkin in order to have a service level tracing system. This will allow me to know where the bottleneck is at the service level.
I am wondering though if there are framework out there to monitor the performance inside my application layer. The application is a suite of filters that are applied consecutively to my data and I would like to know which filter take time to compute. I heard about JVM profiling but it seems a little overkill for what I want to do. What would you recommend ? Thanks for your help.
Well before starting digging into JVM stuff or setting up all the infrastructure needed by Zipkin you could simply start by measuring some application-level metrics.
You could try the library metrics via this scala api.
Basically you manually set up counters and gauges at specific points of your application that will help you diagnose your bottleneck problem.
i have a spring application that i want to optimize , its using much memory, it was fine when few people used it, but numbers scaled a little and i have no idea where to start . Is there a way of knowing which class and methods take what kind of resources ?
I think JMX will be a good start. Using Spring's JMX support, it will be very easy to configure your beans to integrate with JMX.
http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/jmx.html
The best way to start with this is using a profiler. There are a lot of products out there. I personally like YourKit. It's a matter of preference. Using a profiler you can easily find out the number of instantiated classes from where in the code. You might simply have a memory leak.
In general I think it's a good idea to set up your application server/servlet container to expose their internals over JMX. You'll just have to enable the JMX agent by setting JVM startup parameters. You can then connect to your server and monitor CPU and memory consumption using JConsole or VisualVM. VisualVM provides a simple profiling plugin.