Be honest — do you actually know the correct curl syntax for GET and POST, or do you just copy-paste?
Most of us use curl regularly, but the difference between request and response still confuses people.
Here’s a clean breakdown.
GET Request (fetch data)
Request
curl https://t.co/BT0gCOGEsS
Response
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto"
}
POST Request (send data)
Request
curl -X POST https://t.co/kUs4JaDVet \
-H "Content-Type: application/json" \
-d '{"title":"foo","body":"bar","userId":1}'
Response
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
Key difference
• GET → you only send the URL, server returns data
• POST → you send data in the body (-d), server returns the created resource
What’s the curl flag you use the most? Drop it below.
🚀 3 Essential Git Commands Every Developer Should Know!
Ever wondered how to connect your local Git repository to GitHub, push your code for the first time, and track your branches?
Let's understand these 3 commands with a practical example. 👇
🔵 1️⃣ git branch -vv - Check Branch & Tracking Information
git branch -vv
This command displays detailed information about your local branches.
✅ Shows your current branch (*)
✅ Displays the latest commit ID and message
✅ Shows the upstream tracking branch (e.g., origin/main)
✅ Indicates whether your branch is ahead or behind its upstream (when tracking information is available)
Example Output:
* main a1b2c3d [origin/main] Initial commit
dev e4f5g6h [origin/dev: ahead 2] New feature
📌 When to use?
Use it to verify which branch you're working on and whether it is tracking a remote branch.
If no upstream is configured, no [origin/main] information appears.
🟢 2️⃣ git remote add origin - Connect Local Git to GitHub
git remote add origin \
https://t.co/dvJKEwM2qd
This command registers a remote repository named origin in your local Git configuration.
What does it mean?
🔹 remote → Manage remote repositories
🔹 add → Register a new remote
🔹 origin → Conventional name for the remote repository
🔹 URL → Address of your GitHub repository
📌 When to use?
When you've created a local Git repository and want to connect it to an existing GitHub repository for the first time.
Verify the remote:
git remote -v
⚠️ Important: This command does NOT upload your code. It only configures the remote connection.
🟣 3️⃣ git push -u origin main - Push Code & Set Upstream
git push -u origin main
This command pushes your local main branch to GitHub and configures upstream tracking.
Breaking it down:
🔹 push → Upload local commits
🔹 -u → Set upstream tracking (--set-upstream)
🔹 origin → Remote repository name
🔹 main → Branch being pushed
📌 When to use?
When pushing a local branch to GitHub for the first time and you want Git to remember its upstream branch.
After successful execution, your local main tracks origin/main.
Now future pushes can be as simple as:
git push
And to fetch and integrate remote changes:
git pull
(Assuming the usual upstream and push configuration.)
🔥 4️⃣ Complete Workflow - New Spring Boot Project
Suppose you've created a Spring Boot project locally, initialized Git, and committed your code.
Now you want to publish it on GitHub.
Step 1: Check your branch
git branch -vv
Step 2: Connect to GitHub
git remote add origin \
https://t.co/dvJKEwM2qd
Step 3: Push and configure upstream
git push -u origin main
Step 4: Verify tracking
git branch -vv
Expected output:
* main a1b2c3d [origin/main] Initial commit
🎯 5️⃣ Quick Recap
🔍 git branch -vv → Inspect local branches and upstream tracking.
🔗 git remote add origin → Connect your local repository to GitHub.
🚀 git push -u origin main → Push commits and establish upstream tracking.
💡 Remember:
• git remote add origin is normally a one-time setup per remote.
• git push -u is useful the first time you publish a branch.
• git branch -vv can be used anytime to inspect branch tracking.
• origin is just a conventional remote name, not a Git keyword.
One small distinction worth remembering:
git remote add configures WHERE your remote repository is.
git push -u configures WHICH remote branch your local branch tracks, while pushing your commits.
💬 Interview Question: What happens if you run git push on a new local branch that has no upstream configured?
Have you encountered this scenario while working with Git? 👇
#Git #GitHub #Java #SpringBoot #BackendDevelopment #DevOps
Let’s say for a Microservices architecture, if you have 2 services :
1) Users
2) Product
I want to implement caching mechanism, the should I used Redis cache in each service separately or there should be a centralised way to achieve it?
What is the right way to go about it considering we will have more services like Order and Payment etc in the near future?
B gets it from me. Working on a real time application gets real very quickly when something goes wrong.
Candidate A is good but to handle such migrations and incidents, B is an apt choice as in this ever evolving rapid development times. Keeping an app running is more important than writing algorithms which can be done by AI tools efficiently.
B knows the real grind and business cost involved if app goes down. Experience matters more in coordinating and fixing and evolving a set of services than to work on interview specific algorithms.
API Versioning: URI vs Query Param vs Header
Three common ways (header has two popular variants):
1. URI Versioning
GET /api/v1/users
Version lives in the path. Easy to see, route, and cache.
2. Query Parameter Versioning
GET /api/users?version=1
Version passed as a query param. Simple to add, but can get noisy.
3. Header Versioning (two variants)
• Accept / Media type Accept: application/vnd.example.v1+json
• Custom header X-API-Version: 1 (or API-Version: 1)
Clean URLs, more flexible, slightly less obvious to clients.
Quick preference guide
• Public / simple APIs → URI
• Clean mature APIs → Header (Accept or custom)
• Quick/internal → Query param is fine, rarely ideal long-term
Quick preference guide
• Public / simple APIs → URI
• Clean mature APIs → Header (Accept or custom)
• Quick/internal → Query param is fine, rarely ideal long-term
API Versioning: URI vs Query Param vs Header
Three common ways (header has two popular variants):
1. URI Versioning
GET /api/v1/users
Version lives in the path. Easy to see, route, and cache.
2. Query Parameter Versioning
GET /api/users?version=1
Version passed as a query param. Simple to add, but can get noisy.
3. Header Versioning (two variants)
• Accept / Media type Accept: application/vnd.example.v1+json
• Custom header X-API-Version: 1 (or API-Version: 1)
Clean URLs, more flexible, slightly less obvious to clients.
Quick preference guide
• Public / simple APIs → URI
• Clean mature APIs → Header (Accept or custom)
• Quick/internal → Query param is fine, rarely ideal long-term
Quick preference guide
• Public / simple APIs → URI
• Clean mature APIs → Header (Accept or custom)
• Quick/internal → Query param is fine, rarely ideal long-term
B gets it from me. Working on a real time application gets real very quickly when something goes wrong.
Candidate A is good but to handle such migrations and incidents, B is an apt choice as in this ever evolving rapid development times. Keeping an app running is more important than writing algorithms which can be done by AI tools efficiently.
B knows the real grind and business cost involved if app goes down. Experience matters more in coordinating and fixing and evolving a set of services than to work on interview specific algorithms.
You're hiring a senior engineer.
Candidate A solves coding problems quickly.
Candidate B has fewer impressive algorithms but has handled real production failures, migrations, and incidents.
Who gets the offer, and what would you ask before deciding?
Be honest — do you actually know the correct curl syntax for GET and POST, or do you just copy-paste?
Most of us use curl regularly, but the difference between request and response still confuses people.
Here’s a clean breakdown.
GET Request (fetch data)
Request
curl https://t.co/BT0gCOGEsS
Response
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto"
}
POST Request (send data)
Request
curl -X POST https://t.co/kUs4JaDVet \
-H "Content-Type: application/json" \
-d '{"title":"foo","body":"bar","userId":1}'
Response
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
Key difference
• GET → you only send the URL, server returns data
• POST → you send data in the body (-d), server returns the created resource
What’s the curl flag you use the most? Drop it below.
@SumitM_X SELECT *
FROM customers
LIMIT 5 OFFSET 5; page 1 needs to skip i.e 5 records so OFFSET 5 corresponds to that and we need 5 records so LJMIT 5.
Spring Boot: @PostConstruct vs CommandLineRunner
🤔 Do you know the difference between these two?
Both execute automatically during Spring Boot startup, but WHEN they execute and WHY we use them are different.
🔵 1️⃣ @PostConstruct — Bean Initialization
Runs after Spring creates a bean and injects its dependencies, but before that bean's initialization is complete.
✅ When to use?
• Initialize bean-specific caches
• Validate configuration
• Prepare internal resources
• Load reference data needed by the bean
@Component
@Slf4j
public class MyComponent {
@PostConstruct
public void init() {
https://t.co/QrGKNUrzCo("@PostConstruct executed");
}
}
📌 Key point: Runs once per bean initialization, not once globally for the entire application.
🟢 2️⃣ CommandLineRunner — Application Startup Logic
Executes after the Spring application context has been refreshed and the embedded web server has started, but before Spring Boot signals that the application is ready.
✅ When to use?
• Seed initial database records
• Execute startup scripts
• Perform application-level initialization
• Log startup information
@Component
@Slf4j
public class MyRunner
implements CommandLineRunner {
@Override
public void run(String... args) {
https://t.co/QrGKNUrzCo("CommandLineRunner executed");
}
}
📌 Key point: Runs once during application startup for each registered runner bean.
⏳ 3️⃣ Execution Order
1️⃣ Spring creates beans
⬇️
2️⃣ Dependencies are injected
⬇️
3️⃣ @PostConstruct executes during bean initialization
⬇️
4️⃣ Application context refresh completes (web server starts)
⬇️
5️⃣ CommandLineRunner executes
⬇️
6️⃣ ApplicationReadyEvent is published
💡 4️⃣ Important Differences
🔹 @PostConstruct → Bean-level initialization
🔹 CommandLineRunner → Application-level startup logic
🔹 @PostConstruct → No method arguments
🔹 CommandLineRunner → Receives String... args
🔹 @PostConstruct → Executes during bean initialization
🔹 CommandLineRunner → Executes after context refresh
⚡ Bonus: If multiple CommandLineRunner beans exist, use @Order or Ordered to control their execution order.
🎯 Which one should you choose?
Use @PostConstruct when initialization belongs to a specific bean.
Use CommandLineRunner when logic should execute after the application context is initialized.
⚠️ Remember: Neither guarantees that external dependencies are ready, and long-running initialization can delay application readiness.
👇 Have you used both in your Spring Boot projects? Which one do you prefer for startup initialization?
#Java #SpringBoot #BackendDevelopment #Microservices
Client-side vs Server-side Load Balancing
Client-side (Spring Cloud LoadBalancer)
→ Order Service itself decides which User Service instance to call
→ Calls the instance directly
Server-side (Nginx)
→ Order Service only calls Nginx
→ Nginx decides which User Service instance to forward the request to
In both cases Order Service is the client.
The difference is who makes the routing decision.