Skip to the content
Pragmatic Coders
  • Services
        • All Services
        • Software Development
          • Web & Cloud App Development
          • Mobile Application Development
          • No-Code Development
          • Software Project Rescue
          • DevOps Services
        • Custom Fintech Software
          • Trading Software Development
          • Custom Banking Software
          • Custom Financial Software
          • Mobile Banking App Development
          • Blockchain Development
        • Custom Healthcare Software
          • Patient Portal Development
          • Telehealth App Development
          • Custom Physical Therapy Apps
          • Custom Telemedicine Software
          • Custom Patient Engagement Apps
        • AI Software Development
          • AI Agents Development
          • AI Integration Services
          • AI Data Solutions
          • Vibe Coding Rescue
        • Product Design
          • UX Research
          • UX Design
          • UI Design
        • IT outsourcing
          • Nearshore Outsourcing
          • Offshore Outsourcing
          • Build Operate Transfer
  • Industries
        • All Industries
        • Fintech
        • Digital Health
        • E-commerce
        • Entertainment
        • Custom Software Development Services
        • Business Consulting
  • Case Studies
        • All Case Studies
        • FintechExplore our curated fintech case studies, showcasing the cutting-edge software solutions we’ve developed to revolutionize the financial technology landscape.
          • Atom Bank - One Of UK's Top Challenger Banks
          • KodyPay - Payment Platform
          • BLOC-X - OTC Commodity Trading
        • Blockchain
          • Common Wealth: Web3 investing platform
          • UltiArena: Play-to-Earn NFT Hub
          • EXCC - Developing New Blockchain
        • Digital HealthBrowse through our digital health case studies, illustrating how our technology innovations are transforming healthcare, enhancing patient outcomes, and streamlining medical processes with bespoke software solutions.
          • WithHealth - Medical Platform
          • AccentPharm - Medical Translations
          • Health Folder - Medical Documentation Management
        • E-commerce/RetailDiscover our e-commerce case studies, highlighting our development of scalable, user-centric platforms that boost sales, enhance the shopping experience, and streamline operations in the digital marketplace.
          • Kitopi - Smart Kitchen
          • Webinterpret - Cross-platform E-commerce
          • Photochain: Decentralized photo marketplace
        • EntertainmentExplore our case studies in entertainment projects, where creativity converges with technology to create immersive and engaging digital experiences that captivate audiences globally.
          • Unlocked - Events Management
          • Duel - Social Media App
          • OnLive: Decentralized streaming platform
        • AIDive into our AI case studies to discover how artificial intelligence is applied to solve complex challenges, improve decision-making, and increase efficiency across various industries with our advanced solutions.
          • Accounting Automation
          • US Patient Care Platform | AI & Data Science
  • About us
        • About us
        • Meet Our Team
        • How We Work
        • Become a Partner
        • News
        • Join Us!
  • Blog
        • All curated categories
        • Authors
        • FintechInterested in the development of a new custom fintech product? Check our articles about new fintech trends and fintech product development. If you are looking for experienced fintech software development partners do not forget to check our fintech software development services. You may also find interesting our blockchain development services.
        • Digital HealthDigital health encompasses the use of technology and data to improve healthcare delivery and patient outcomes. If you want to build a digital health app, check out our healthcare software development services.
        • Blockchain
        • AI
        • Product Development
        • Product Management
        • Product DesignA successful product needs to be well planned and tested by its users as early as possible. Here we share our knowledge and experience from more than 60 startups we helped build in the last years.
        • Agile & Scrum
        • Startup
        • Outsourcing & Collaboration
  • Resources
        • All Resources
        • Tools
          • Market Insights AI
          • Trade Easy AI
        • Guides
          • Fintech guide
          • Digital health guide
          • Insurtech guide
          • AI trends
        • Other
          • Newsletter
          • Glossary
          • Product Health Checklist
          • Best AI for coding in 2025: AI tools for developers
          • 60 startup business model patterns for 2025
        • Ebooks
          • How to start a startup
          • How to go live with your product in less than 3 months
        • Video
          • Podcast
          • Webinars
  • Contact us
Congrats, you are up to date! Now you can impress your friends with your cutting-edge knowledge.
Mark all as read
Contact Us
Home Pragmatic Blog Product Development Building Efficient CI/CD Pipelines and Optimizing Java Memory for Kubernetes
Product Development
Updated: Jan 09,2025 Published: Jan 10,2025
3 min read

Building Efficient CI/CD Pipelines and Optimizing Java Memory for Kubernetes

Optimizing CICD Pipelines & Java Memory for Kubernetes

Efficient CI/CD pipelines and optimized Java memory management are essential for modern backend systems, especially in containerized environments like Kubernetes.

This guide provides practical steps to streamline deployments and configure Java memory to prevent resource overages and pod failures.

 

PRODUCT DEVELOPMENT SERVICES

Basic implementation details

The basic backend CI/CD pipeline should consist of the following steps:

  1. Build step
    1. Compile/transpile the application
    2. Run unit tests
    3. Run integration tests
    4. Run a static code analysis
    5. Create a docker image (use Git rev number for the image name)
    6. It should be executed on the main and feature branches (the build should run on each branch, even without an explicit Pull Request)
  2. Package step
    1. Upload docker image to AWS ECR
    2. Use AWS credentials as secret variables in GitHub actions
    3. It should be executed on the main branch only
  3. Deploy to dev
    1. Download the docker image
    2. Deploy to EKS or other docker orchestration tool delivered by the DevOps team
    3. It should be executed on the main branch only
  4. Deploy to prod
    1. By default, it should be started manually by pushing a button ad hoc
    2. Download the docker image
    3. Deploy to EKS or other docker orchestration tool delivered by the DevOps team
    4. It should be executed on the main branch only

Java memory configuration (Tested on JVM 21)

Starting with version 10, the JVM uses the -XX:+UseContainerSupport option by default, which should address memory management issues in containerized environments. However, it doesn’t work as expected. According to the documentation:


“If your application is running in a container that imposes a memory limit, the VM allocates a larger fraction of memory to the Java heap.” docs

This setting only controls the heap memory. What other memory areas does the JVM use and allocate separately from the heap?

  • Java Heap
  • Metaspace
  • Thread
  • Code
  • GC
  • Compiler
  • Internal
  • Other
  • Symbol
  • And there are a few others whose purposes I am not entirely sure about.

So, how can you configure a Java process to avoid being killed for exceeding the memory limits of a Kubernetes pod? The key is to reserve memory for the largest allocations and leave a buffer for the rest. A good configuration might include:

  • -Xms400m -Xmx400m – allocates a fixed 400 MB for the heap, ensuring that the pod’s memory usage reflects the full heap allocation from the start. For most Java applications, 400 MB should be sufficient, or it could even be reduced further if needed.
  • -XX:MaxMetaspaceSize=150m – sets a limit for Metaspace, which stores metadata like class definitions, method data, and field data. This allocation is often a significant portion of memory, so it’s important to set a cap.
  • -XX:ReservedCodeCacheSize=128m -XX:+UseCodeCacheFlushing – the code cache is responsible for storing JIT-optimized code for frequently used code blocks. By default, the JVM does not release this memory, but enabling code cache flushing allows it to remove outdated or unused optimizations.
  • Each thread reserves approximately 1 MB of memory.

How much memory will the application use? To determine how much memory to reserve for the pod, you can use this formula:


Java heap + Metaspace + Code Cache + Threads + 100 MB buffer

For a deeper analysis of JVM memory usage, consider tools like Native Memory Tracking or JProfiler. These tools require setup but provide detailed insights into each memory category.

By implementing the outlined CI/CD steps and fine-tuning Java memory settings, you can ensure efficient workflows and stable applications in Kubernetes. These practices help minimize downtime, optimize resource usage, and simplify deployments. Start with the basics, refine as needed, and let your infrastructure work for you.

CICD Pipeline and Java Memory Optimizing Services

Author

Marcin Byrdziak View profile

Marcin Byrdziak

Marcin identifies projects needs and provides all necessary resources to meet them. He also cares about the highest quality of services and constant improvement through retrospectives. If you start cooperating with Pragmatic Coders, you will meet him during the kick-off meeting. He spends his free time dancing salsa.

Newsletter
Recent Topics
Top AI Tools for Traders in 2025 cover
Fintech, AI
Top AI Tools for Traders in 2025
Expert sourcing with multi-agent AI
News, AI
Multi-Agent AI Systems for Expert Sourcing & Workflow Automation
Top AI Integration Companies in 2025 cover
AI, Product Development
Top AI Integration Companies in 2025
Gen Alpha Statistics 2025
Product Design, Management
Generation Alpha Statistics (220+ stats for 2025)
6 Untapped Gen Alpha Financial Habits Your Next Digital Product Needs to Know
UX, Product Design
What Are Gen Alpha’s Money Habits and How Can They Inspire Product Design?

Related articles

Check out our blog and collect knowledge on how to develop products with success.

Top AI Tools for Traders in 2025 Top AI Tools for Traders in 2025 cover
Fintech, AI
Jun 13,2025
20 min read

Top AI Tools for Traders in 2025

Multi-Agent AI Systems for Expert Sourcing & Workflow Automation Expert sourcing with multi-agent AI
News, AI
Jun 13,2025
3 min read

Multi-Agent AI Systems for Expert Sourcing & Workflow Automation

Top AI Integration Companies in 2025 Top AI Integration Companies in 2025 cover
AI, Product Development
Jun 10,2025
20 min read

Top AI Integration Companies in 2025

Our Core Software Development Services

Custom Software Development Services

Custom Software Development Services

Custom Software Development Services for Startups & Tech. Bespoke software built by experts in contemporary software product development.
Learn More
Custom Fintech Software Development Services Company

Custom Fintech Software Development Services Company

Custom Fintech Software Development Services from industry experts. Scalable fintech apps, trading platforms, challenger banks, blockchain, and more.
Learn More
Healthcare Software Development Company

Healthcare Software Development Company

Healthcare software development services from industry experts. We have 10 years of experience in this highly regulated and demanding space.
Learn More
Custom AI Software Development Services & Solutions Company

Custom AI Software Development Services & Solutions Company

We can build your AI app from scratch or implement AI solutions to your existing product. Get a free consultation today!
Learn More

Newsletter

You are just one click away from receiving our 1-min business newsletter. Get insights on product management, product design, Agile, fintech, digital health, and AI.

LOOK INSIDE

Pragmatic times Newsletter
  • Business Consulting
  • Product Discovery Workshops
  • Product Management Consulting
  • Fundraising Consulting
  • Software Product Design
  • UX Design
  • UX Research
  • UI Design
  • Custom Software Development-services
  • Web & Cloud Application Development
  • Mobile Application Development
  • No-code Development
  • AI Software Development
  • Custom Blockchain Development
  • DevOps Services
  • Technology Consulting
  • Industries
  • Fintech
  • Digital Health
  • E-commerce
  • Entertainment
  • Custom Software Development Services
  • About Us
  • Meet Our Team
  • How We Work
  • Become a Partner
  • Newsroom
  • Featured Case Studies
  • Atom Bank
  • Kitopi
  • WithHealth
  • UltiArena
  • Resources
  • Digital Health Guide
  • Fintech Guide
  • Insurtech Guide
  • Newsletter
  • E-books
  • Podcast & Webinars
  • Blog
  • Product Development
  • Fintech
  • Digital Health
  • AI
  • Product Management
  • Agile & Scrum
  • Outsourcing & Collaboration
  • Blockchain
  • Startup
Pragmatic Coders Logo

ul. Opolska 100

31-323 Kraków, Poland

VAT ID: PL 6772398603

Contact

[email protected]

+48 783 871 783

Follow Us
Facebook Linkedin Github Behance Dribbble
© 2025 Pragmatic Coders. All right reserved.
  • Privacy policy
  • Terms of use
  • Sitemap