Optimizing vCore Utilization in MuleSoft-Part 1

Rohit Malik
Another Integration Blog
5 min readJul 17, 2024

A Comprehensive Guide

Introduction

In the realm of enterprise integration, MuleSoft stands out as a powerful tool, enabling businesses to connect applications, data, and devices seamlessly. At the heart of MuleSoft’s runtime engine, Anypoint Platform, are vCores — virtual computing resources crucial for processing and managing integrations. Efficient utilization of vCores is vital for cost management and optimal performance.

This blog will explore strategies and best practices to optimize vCore utilization in MuleSoft. We will also discuss how on-demand execution and termination of batch applications can significantly save and optimize vCore usage. As this is a two-part blog, we will cover best practices and the context of on-demand execution and termination in this first part. In the second part, we will delve into implementing the on-demand execution and termination of batch jobs.

Understanding vCores in MuleSoft

vCores, or virtual cores, represent the computational power allocated to your Mule applications. Each vCore consists of CPU, memory, and other resources necessary to run MuleSoft applications. Efficient use of these resources ensures your applications run smoothly, handle loads effectively, and avoid unnecessary costs.

Real-Time Applications vs. Batch Jobs

MuleSoft applications can generally be classified into real-time applications and batch jobs. Real-time applications require continuous processing and instant responses, while batch jobs handle large volumes of data at scheduled intervals.

MuleSoft calculates vCore usage only when applications are running. When they are inactive, the vCore usage is freed up. Therefore, it is wise to run batch jobs only when they need to process records and turn them down when unnecessary. This strategy ensures optimal vCore utilization.

Strategies for Optimizing vCore Utilization

Right-Sizing Your Deployments

Properly sizing your deployments is the first step towards optimizing vCore utilization. Over-provisioning leads to wasted resources, while under-provisioning can cause performance bottlenecks.

  • Analyze Load Patterns: Understand your application’s load patterns and traffic volumes. Use historical data to predict peak loads and average usage.
  • Adjust vCore Allocation: Allocate vCores based on your applications’ actual requirements. Scale up during peak times and scale down during off-peak periods.

Performance and Load Testing

Conducting performance and load testing before sizing your APIs is essential for ensuring optimal vCore utilization. This can be done after User Acceptance Testing (UAT) and before production deployment.

  • Burst Out the Peak Load: Simulate the highest-demand scenarios to test how much resource is needed to make the API run normally.
  • Performance Testing: Using historical data and general assumptions, performance testing determines how many resources are needed for normal operations. The load size gradually increases until it bursts out to find the maximum load the API can handle during peak times.
  • Monitoring Resource Utilization: Regularly monitor resource utilization and decide whether to upscale (vertically) or out-scale (horizontally) based on the observed data.

Efficient Application Design

Designing your applications efficiently can lead to significant improvements in vCore utilization.

  • Use Asynchronous Processing: Whenever possible, use asynchronous processing to handle tasks that do not require immediate responses. This reduces the load on your vCores.
  • Implement Caching: Caching frequently accessed data can reduce the need for repeated processing, thereby saving vCore resources. Only safe HTTP methods, such as GET, should be cached for caching. Caching should be considered if the GET response for any API resource is generally static and changes rarely. Be mindful of the cache size restriction in CloudHub, as this should also be considered while implementing caching.

Leveraging CloudHub Features

CloudHub, MuleSoft’s integration platform as a service (iPaaS), offers several features that can help optimize vCore usage.

  • Autoscaling: CloudHub’s autoscaling feature automatically adjusts the number of workers (and thus vCores) based on the current load. This ensures that you only use the resources you need at any given time.
  • Worker Size Management: Choose the appropriate worker size (e.g., micro, small, medium) based on your application’s requirements. When deciding whether to size up vCores or add more workers, consider the nature of your API’s workload. If the logic in the API is more memory-intensive and deals with large-sized payloads, then opting for higher vCores is suggested. If the computation is simple and less memory-intensive but handles a high volume of requests in short intervals, adding extra workers with smaller vCores would be more efficient.

Monitoring and Analytics

Continuous monitoring and analysis are crucial for maintaining optimal vCore utilization.

Anypoint Monitoring: Use Anypoint Monitoring to gain insights into your application’s performance and resource usage. Identify trends, detect anomalies, and make informed scaling and resource allocation decisions.
Custom Dashboards: Create custom dashboards to monitor key metrics such as CPU usage, memory consumption, and response times. This will help identify areas for optimization.

Best Practices for Development

Adopting best practices during the development phase can significantly impact vCore utilization.

Modular Design: Designing your applications modularly can significantly enhance vCore utilization. One example is breaking down a large, monolithic API into smaller, domain-specific APIs.

Example: Instead of designing a single netsuite-system-api, break it down into billing-system-api, payments-system-api, etc. This approach distributes the traffic and logic across separate systems and process APIs. System APIs should be designed based on a domain, not the entire system. This modular design ensures that only the necessary components are deployed, reducing the overall load on vCores.

Code Optimization: Write clean, efficient code. Avoid redundant processing and optimize algorithms to reduce the computational load.
Error Handling: Implement robust error handling to avoid unnecessary retries and processing, which can consume additional vCores.

Regular Audits and Reviews

Conducting regular audits and reviews of your applications and their resource utilization helps maintain optimal vCore usage.

Resource Utilization Audits: Periodically review your applications' resource utilization. Identify any inefficiencies and make necessary adjustments.
Performance Testing: Regularly perform load and performance testing to ensure your applications use vCores efficiently under different scenarios.

Savings Through On-Demand Execution and Termination of Batch Applications

Over time, organizations have observed a roughly 60/40% ratio between real-time and batch job applications. While the previously mentioned strategies are effective in optimizing vCore usage, an additional method can further enhance efficiency: on-demand execution and stopping of batch applications.

Organizations can free up vCore space by scheduling batch jobs to run only when necessary and stopping them immediately after execution. This approach involves timing the scheduling of jobs so that they are active only when needed and turned off when not in use. This strategy ensures optimal vCore utilization, minimizing resource waste.

Implementing this method yields excellent returns on investment, maximizing the efficiency of the allocated vCores and ensuring that resources are used only when required.

Conclusion

Optimizing vCore utilization in MuleSoft is essential for achieving cost efficiency and ensuring high integration performance. You can significantly enhance your vCore utilization by right-sizing deployments, designing efficient applications, leveraging CloudHub features, monitoring resource usage, conducting performance and load testing, adhering to development best practices, and conducting regular audits.

Implement these strategies to maximize your MuleSoft environment and ensure your integrations are robust, reliable, and cost-effective.

Happy integrating! I will see you in the next part of this blog post.

--

--