Saturday, June 21, 2025

JBoss - Few Old questions around 2016 era

 What is JBoss?

–          JBoss is a popular open source application server based on Java EE technology. Being Java EE

based, the JBoss supports cross-platform java applications.

What is jboss EAP?

–          JBoss Enterprise Application Platform is an open source implementation of the Java EE suite of

services.

How do you deploy an application to JBoss?

– Choose the server profile to which you want to deploy the application.

Copy your application (for example: .war or .ear or a .jar file) to

JBOSS_HOME/server/<profilename>/deploy folder.

Start the server.

JBoss will deploy your application when it boots up. 

How do you perform a hot deployment?

–          JBoss has a built-in hot deployer which can:

o Detect new applications in the deploy folder and trigger an application deployment

o Detect an application which was removed from the deploy folder and trigger an application

undeployment

o Detect that the deployment descriptor of an application (for example, the web.xml of .war or

application.xml of .ear) has changed and trigger an application redeployment

 

How do you enable/disable a hot deployment?

–          To enable, put file hdscanner-jboss-beans.xml in  JBOSS_HOME/server/<profilename>/deploy

–          To disable hot deployment, remove the hdscanner-jboss-beans. xml from the deploy folder or

rename it to hdscanner-jbossbeans. xml.bak (.bak files are ignored).

 


How can you configure the time for the hot deployer?

–          “scanPeriod” in hdscanner-jboss-beans.xml

 

How do you setup JBoss cluster??

–          Getting started with JBoss clustering is very simple. If two JBoss server instances using the all

configuration are started on the same network, those servers will detect each other and automatically

form a cluster.

–          Two application servers running on the same network detect each other auto and form cluster.

What are needed to set-up a cluster with JBoss ?

–          Basically starting JBoss with the \'all\' configuration contains everything needed for clustering:

 Which component handles cluster communication in JBoss?

–          The JGroups framework provides services to enable peer-to-peer communications between

nodes in a cluster. It is built on top a stack of network communication protocols that provide transport,

discovery, reliability and failure detection, and cluster membership management services.


What do you check if you are having problems starting up JBoss?

–          First thing to check is whether JAVA_HOME variable is set, then check the server logs.


How do you monitor JBoss and detect the bottleneck of an application?

–          The first step is to measure the different components of your app to see where the degradation

is. Is it an external resource (database, message server, etc.)? Is it internal? Where is the app spending

all its time?

So the first step could be to to use JBoss JMX agents and monitor the components deployed to the

application server. Once it\'s clear which component or library takes most of the time or most of

resource you can use a more specialized tool like JProbe and examine the single method or the single

objects loaded in memory.


Is it possible to put a JBoss server instance into multiple cluster at the same time?

–          It is technically possible to put a JBoss server instance into multiple clusters at the same time, this

practice is generally not recommended, as it increases the management complexity.

What is JBoss cache in short?

–          JBoss cache is a product. Frequently accessed Java objects are cached by utilzing JBoss cache to

improve the performance of e-business applications. JBoss decreases the network traffic and increases

the scalability of applications by eliminating unnecessary database access.

Wednesday, June 11, 2025

Virtual Machines (VMs) Vs Containers

 

1. Architecture

  • Virtual Machine (VM)

    • Runs a full guest OS (e.g., Linux, Windows) on top of a hypervisor (e.g., VMware, Hyper-V, KVM).

    • Each VM includes the OS kernel, libraries, apps, and virtualized hardware (CPU, RAM, disk).

    • Hypervisor abstracts physical hardware for multiple VMs.

  • Container

    • Shares the host OS kernel (via a container runtime like Docker, containerd).

    • Packages only the app, dependencies, and libraries into an isolated lightweight process.

    • Uses OS-level virtualization (cgroups, namespaces in Linux).


2. Resource Efficiency

AspectVirtual MachinesContainers
Disk SpaceLarge (GBs per VM, includes OS)Small (MBs, shares host OS)
RAM/CPUHigher overhead (dedicated OS)Minimal overhead
Startup TimeSlow (minutes)Near-instant (seconds)
PerformanceSlight overhead (hardware emulation)Near-native (direct kernel access)

3. Isolation & Security

  • VMs:

    • Strong isolation (each VM has its own OS/kernel).

    • Better suited for multi-tenant security (e.g., untrusted workloads).

  • Containers:

    • Process-level isolation (less strict; kernel vulnerabilities affect all containers).

    • Security relies on host OS hardening and tools (e.g., seccomp, AppArmor).


4. Portability & Deployment

  • Containers:

    • Highly portable: Build once, run anywhere (Linux/Windows hosts, cloud).

    • Defined via Dockerfile → immutable image (e.g., Docker Hub).

    • Ideal for CI/CD pipelines and microservices.

  • VMs:

    • Portable as disk images (e.g., OVA, VHD), but tied to hypervisor compatibility.

    • Better for legacy apps needing full OS environments.


5. Use Cases

  • Use Containers When:

    • Deploying microservices, stateless apps, or cloud-native workloads.

    • Needing rapid scaling (e.g., Kubernetes orchestration).

    • Optimizing resource usage (high density per host).

  • Use VMs When:

    • Running legacy apps requiring specific OS/kernel versions.

    • Handling security-critical workloads (e.g., PCI compliance).

    • Needing full OS control (e.g., custom kernel modules).


6. Management & Ecosystem

  • Containers:

    • Orchestrated via Kubernetes, Docker Swarm, etc.

    • Infrastructure-as-Code tools (e.g., Terraform, Helm).

  • VMs:

    • Managed with VMware vSphere, OpenStack, or cloud tools (AWS EC2, Azure VMs).

    • Configuration tools (e.g., Ansible, Puppet).


Hybrid Approach

  • Containers inside VMs: Common in production (e.g., Kubernetes nodes run as VMs). Combines VM security with container agility.

Summary Table

FeatureVirtual MachinesContainers
OSFull guest OS per VMShares host OS kernel
OverheadHighLow
Boot TimeSlow (minutes)Fast (seconds)
SecurityStrong (hardware-level isolation)Moderate (kernel-dependent)
Resource UsageHeavyLightweight
Image SizeGBsMBs
ScalingSlower (VM provisioning)Faster (orchestration tools)
Use Case FitLegacy apps, strict isolationMicroservices, cloud-native

Bottom Line

  • Containers excel in agility, density, and modern app deployment.

  • VMs provide stronger isolation and OS flexibility for traditional workloads.

  • Many systems combine both (e.g., containers orchestrated across VM clusters).

Monday, June 9, 2025

Troubleshoot API-Gateway

 

Create a Proper Test Controller

java
Copy
Download
package com.example.api_gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }
}

@RestController
class TestController {
    
    @GetMapping("/gateway-test")
    public String testEndpoint() {
        return "Gateway is working properly!";
    }
}

2.Verify Service Accessibility

Create a simple test to ensure your greet service is reachable:

java
Copy
Download
package com.example.api_gateway;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
class ServiceHealthCheck {
    
    @Bean
    public String checkGreetService() {
        WebClient.create("http://localhost:8001")
            .get()
            .uri("/greet")
            .retrieve()
            .toBodilessEntity()
            .subscribe(
                response -> System.out.println("Greet service is UP! Status: " + response.getStatusCode()),
                error -> System.err.println("Greet service is DOWN! Error: " + error.getMessage())
            );
        return "Health check initiated";
    }
}

3. Final Troubleshooting Steps

  1. Remove any existing build artifacts:

    bash
    Copy
    Download
    mvn clean package
  2. Check for port conflicts:

    bash
    Copy
    Download
    netstat -ano | findstr :9191
    netstat -ano | findstr :8001
  3. Verify service response:

    bash
    Copy
    Download
    curl -v http://localhost:8001/greet
  4. Test gateway endpoints:

    bash
    Copy
    Download
    curl -v http://localhost:9191/gateway-test
    curl -v http://localhost:9191/greet

Expected Behavior After Fix

  1. http://localhost:9191/gateway-test should return:

    text
    Copy
    Download
    Gateway is working properly!
  2. http://localhost:9191/greet should proxy to your service at http://localhost:8001/greet

If You Still Encounter Issues

Add this controller to debug routing:

java
Copy
Download
package com.example.api_gateway;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DebugConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
            .route("debug-greet-route", r -> r
                .path("/greet/**")
                .filters(f -> f.rewritePath("/greet/(?<segment>.*)", "/${segment}"))
                .uri("http://localhost:8001"))
            .route("direct-test", r -> r
                .path("/direct-test")
                .uri("http://httpbin.org/get"))
            .build();
    }
}

Then test:

text
Copy
Download
http://localhost:9191/direct-test

This should return a response from httpbin.org, proving your gateway is working. If this works but /greet doesn't, the issue is with your service or the URI configuration.