<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ravi Pandey on Medium]]></title>
        <description><![CDATA[Stories by Ravi Pandey on Medium]]></description>
        <link>https://medium.com/@dev_RV?source=rss-8ff31e513e57------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Nv7aNdQ6E5RwFOBPq2Kdzw.jpeg</url>
            <title>Stories by Ravi Pandey on Medium</title>
            <link>https://medium.com/@dev_RV?source=rss-8ff31e513e57------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:01:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dev_RV/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Most frequently asked SQL interview queries.]]></title>
            <link>https://medium.com/@dev_RV/most-frequently-asked-sql-interview-queries-4a347de37cba?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a347de37cba</guid>
            <category><![CDATA[query]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 09:34:30 GMT</pubDate>
            <atom:updated>2026-11-12T09:34:30.466Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Second highest salary</h3><pre>SELECT MAX(salary)<br>FROM employee<br>WHERE salary &lt; (SELECT MAX(salary) FROM employee);</pre><p>Better interview answer if duplicates matter:</p><pre>SELECT salary<br>FROM (<br>    SELECT salary,<br>           DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk<br>    FROM employee<br>) t<br>WHERE rnk = 2;</pre><h3>2. Employees earning more than their department average</h3><p>Very commonly asked.</p><pre>SELECT e.*<br>FROM employee e<br>WHERE e.salary &gt; (<br>    SELECT AVG(e2.salary)<br>    FROM employee e2<br>    WHERE e2.department_id = e.department_id<br>);</pre><p>Also know the JOIN + GROUP BY approach.</p><h3>3. Find duplicate records</h3><pre>SELECT email, COUNT(*)<br>FROM employee<br>GROUP BY email<br>HAVING COUNT(*) &gt; 1;</pre><h3>4. Employees with maximum salary in each department</h3><pre>SELECT *<br>FROM (<br>    SELECT e.*,<br>           DENSE_RANK() OVER (<br>               PARTITION BY department_id<br>               ORDER BY salary DESC<br>           ) rnk<br>    FROM employee e<br>) t<br>WHERE rnk = 1;</pre><h3>5. Top 3 salaries in each department</h3><pre>SELECT *<br>FROM (<br>    SELECT e.*,<br>           DENSE_RANK() OVER (<br>               PARTITION BY department_id<br>               ORDER BY salary DESC<br>           ) rnk<br>    FROM employee e<br>) t<br>WHERE rnk &lt;= 3;</pre><h3>6. INNER JOIN vs LEFT JOIN</h3><p>Example:</p><pre>SELECT e.name, d.name<br>FROM employee e<br>INNER JOIN department d<br>    ON e.department_id = d.id;</pre><p>vs.</p><pre>SELECT e.name, d.name<br>FROM employee e<br>LEFT JOIN department d<br>    ON e.department_id = d.id;</pre><p><strong>Interview trap:</strong></p><pre>SELECT e.*<br>FROM employee e<br>LEFT JOIN department d<br>    ON e.department_id = d.id<br>WHERE d.name = &#39;IT&#39;;</pre><p>This effectively behaves like an inner join for that condition.</p><h3>7. Employees who don’t belong to any department</h3><pre>SELECT e.*<br>FROM employee e<br>LEFT JOIN department d<br>    ON e.department_id = d.id<br>WHERE d.id IS NULL;</pre><h3>8. Department-wise employee count</h3><pre>SELECT department_id, COUNT(*) AS employee_count<br>FROM employee<br>GROUP BY department_id;</pre><p>Follow-up:</p><p><strong>Departments having more than 5 employees</strong></p><pre>SELECT department_id, COUNT(*) AS employee_count<br>FROM employee<br>GROUP BY department_id<br>HAVING COUNT(*) &gt; 5;</pre><p>Remember:</p><blockquote><em>WHERE filters rows </em><strong><em>before grouping</em></strong><em>.<br></em><em>HAVING filters groups </em><strong><em>after grouping</em></strong><em>.</em></blockquote><h3>9. WHERE vs HAVING</h3><p>Classic interview question.</p><pre>SELECT department_id, AVG(salary)<br>FROM employee<br>WHERE salary &gt; 50000<br>GROUP BY department_id<br>HAVING AVG(salary) &gt; 70000;</pre><p>Execution concept:</p><p>FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY</p><p>Don’t blindly memorize the entire logical order, but understand it.</p><h3>10. Find employees whose salary is greater than their manager</h3><p>Query:</p><pre>SELECT e.name<br>FROM employee e<br>JOIN employee m<br>    ON e.manager_id = m.id<br>WHERE e.salary &gt; m.salary;</pre><p>This is a <strong>self join</strong>.</p><h3>11. Find nth highest salary</h3><p>Don’t write a different query for every N.</p><pre>SELECT salary<br>FROM (<br>    SELECT salary,<br>           DENSE_RANK() OVER (ORDER BY salary DESC) rnk<br>    FROM employee<br>) t<br>WHERE rnk = 3;</pre><p>Be ready to explain:</p><ul><li>ROW_NUMBER()</li><li>RANK()</li><li>DENSE_RANK()</li></ul><p>Example salaries:</p><p>100, 100, 90, 80</p><h3>12. Employees who joined in the last 30 days</h3><p>Depends on database, but conceptually:</p><pre>SELECT *<br>FROM employee<br>WHERE joining_date &gt;= CURRENT_DATE - INTERVAL &#39;30&#39; DAY;</pre><p>Know that <strong>date syntax varies between MySQL, PostgreSQL, Oracle, SQL Server</strong>.</p><h3>13. Find employees with same salary</h3><pre>SELECT salary, COUNT(*)<br>FROM employee<br>GROUP BY salary<br>HAVING COUNT(*) &gt; 1;</pre><p>To retrieve employees:</p><pre>SELECT *<br>FROM employee<br>WHERE salary IN (<br>    SELECT salary<br>    FROM employee<br>    GROUP BY salary<br>    HAVING COUNT(*) &gt; 1<br>);</pre><h3>14. Find departments having no employees</h3><pre>SELECT d.*<br>FROM department d<br>LEFT JOIN employee e<br>    ON d.id = e.department_id<br>WHERE e.id IS NULL;</pre><h3>15. Find employees whose name starts with ‘A’</h3><pre>SELECT *<br>FROM employee<br>WHERE name LIKE &#39;A%&#39;;</pre><p>Other important patterns</p><pre>LIKE &#39;%A&#39;      -- ends with A<br>LIKE &#39;%A%&#39;     -- contains A<br>LIKE &#39;_A%&#39;     -- second character A</pre><h3>16. Count NULL values</h3><pre>SELECT COUNT(*)<br>FROM employee<br>WHERE manager_id IS NULL;</pre><p>Important:</p><pre>COUNT(manager_id)</pre><p>does <strong>not</strong> count NULL values.</p><pre>COUNT(*)</pre><p>counts rows.</p><p>This is a frequent interview trap.</p><p>These are where I’d spend time because you’re interviewing for <strong>Senior Java Developer</strong> roles.</p><h3>17. What is a window function?</h3><p>Example:</p><pre>SELECT name,<br>       department_id,<br>       salary,<br>       AVG(salary) OVER (<br>           PARTITION BY department_id<br>       ) AS dept_avg_salary<br>FROM employee;</pre><p>Then:</p><pre>SELECT *<br>FROM (<br>    SELECT e.*,<br>           AVG(salary) OVER (<br>               PARTITION BY department_id<br>           ) AS dept_avg<br>    FROM employee e<br>) t<br>WHERE salary &gt; dept_avg;</pre><h3>18. Running total</h3><pre>SELECT employee_id,<br>       salary,<br>       SUM(salary) OVER (<br>           ORDER BY employee_id<br>       ) AS running_total<br>FROM employee;</pre><p>Understand:</p><pre>PARTITION BY<br>ORDER BY<br>ROWS BETWEEN</pre><h3>19. Find consecutive/duplicate transactions</h3><p>For example, identifying repeated transactions by the same customer.</p><p>You should understand LAG():</p><pre>SELECT customer_id,<br>       transaction_date,<br>       amount,<br>       LAG(amount) OVER (<br>           PARTITION BY customer_id<br>           ORDER BY transaction_date<br>       ) AS previous_amount<br>FROM transactions;</pre><p>Know:</p><ul><li>LAG()</li><li>LEAD()</li><li>ROW_NUMBER()</li><li>RANK()</li><li>DENSE_RANK()</li></ul><h3>20. Find employees who have never received a bonus</h3><p>Two common approaches:</p><pre>SELECT e.*<br>FROM employee e<br>LEFT JOIN bonus b<br>    ON e.id = b.employee_id<br>WHERE b.employee_id IS NULL;</pre><p>or:</p><pre>SELECT *<br>FROM employee e<br>WHERE NOT EXISTS (<br>    SELECT 1<br>    FROM bonus b<br>    WHERE b.employee_id = e.id<br>);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a347de37cba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most asked Java Backend Interview Questions — Senior Experience]]></title>
            <link>https://medium.com/@dev_RV/most-asked-java-backend-interview-questions-senior-experience-db38fd1005b1?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/db38fd1005b1</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[interview-questions]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 06:22:57 GMT</pubDate>
            <atom:updated>2026-09-16T06:22:57.078Z</atom:updated>
            <content:encoded><![CDATA[<p>Topic wise questions list below-</p><h4><strong>1. Core Java</strong></h4><p>OOP<br> Explain OOP principles with real-world examples.<br> What is encapsulation?<br> Abstraction vs encapsulation?<br> Inheritance vs composition?<br> Interface vs abstract class?<br> What is polymorphism?<br> Compile-time vs runtime polymorphism?<br> Method overloading vs overriding?<br> Can static/private/final methods be overridden?<br>equals / hashCode / String<br> Why override equals() and hashCode() together?<br> What happens if equals() is overridden but hashCode() isn’t?<br> How does HashMap use hashCode() and equals()?<br> String vs StringBuilder vs StringBuffer?<br> Why is String immutable?<br> What is String Pool?<br> new String(“abc”) vs “abc”?<br> Why is String immutable useful in Java?<br> Collections<br> ArrayList vs LinkedList<br> ArrayList vs Vector<br> HashMap vs Hashtable<br> HashMap vs ConcurrentHashMap<br> HashSet vs LinkedHashSet vs TreeSet<br> HashMap vs LinkedHashMap vs TreeMap<br> Comparable vs Comparator<br> Fail-fast vs fail-safe<br> How does ArrayList work internally?<br> How does HashMap work internally?<br> What happens during a HashMap collision?<br> What is load factor?<br> Why is ConcurrentHashMap thread-safe?<br> Can HashMap have null keys/values?<br> Java 8 / Streams<br> What is a functional interface?<br> Lambda expression<br> Method reference<br> Stream API<br> map() vs flatMap()<br> filter()<br> sorted()<br> reduce()<br> groupingBy()<br> partitioningBy()<br> How do you find duplicates using Streams?<br> How do you group employees by department?<br> How do you find the second-highest salary using Streams?<br> Can a Stream be reused?<br> Intermediate vs terminal operations?<br> findFirst() vs findAny()<br> map() vs filter()<br> Sequential vs parallel stream?<br> Optional — why and when to use it?<br> Exception Handling<br> Checked vs unchecked exception<br> Exception vs Error<br> throw vs throws<br> Can we have multiple catch blocks?<br> Finally block<br> Can finally be skipped?<br> Custom exception<br> What happens if an exception occurs inside finally?</p><h4><strong>2. Multithreading</strong></h4><p>Process vs thread<br> Thread vs Runnable<br> Runnable vs Callable<br> What is ExecutorService?<br> Why use ExecutorService?<br> FixedThreadPool vs CachedThreadPool<br> What is ThreadPoolExecutor?<br> Core pool size vs maximum pool size<br> What happens when thread pool is full?<br> Future vs CompletableFuture<br> How does CompletableFuture work?<br> thenApply() vs thenCompose()<br> thenApply() vs thenAccept()<br> How to execute multiple CompletableFuture tasks in parallel?<br> synchronized keyword<br> synchronized method vs synchronized block<br> volatile keyword<br> Does volatile guarantee atomicity?<br> AtomicInteger<br> Race condition<br> Deadlock<br> How do you prevent deadlock?<br> Thread safety<br> Lock vs synchronized<br> ReentrantLock<br> Producer-Consumer problem<br> ConcurrentHashMap<br> What happens when multiple threads update the same variable?</p><h4><strong>3. JVM</strong></h4><p>JVM memory areas<br> Heap vs Stack<br> Young generation vs Old generation<br> Eden / Survivor spaces<br> Minor GC vs Major/Full GC<br> How does Garbage Collection work?<br> What causes memory leaks in Java?<br> OutOfMemoryError<br> StackOverflowError<br> Class loading<br> ClassLoader<br> How would you investigate high memory usage?<br> How would you troubleshoot frequent GC?</p><h4><strong>4. Spring / Spring Boot</strong></h4><p>Spring Core<br> What is IoC?<br> What is Dependency Injection?<br> Constructor vs field injection<br> Why prefer constructor injection?<br> What is a Spring Bean?<br> Bean lifecycle<br> Bean scopes<br> Singleton vs prototype<br> <a href="http://twitter.com/Component">@Component</a><br> <a href="http://twitter.com/Service">@Service</a><br> <a href="http://twitter.com/Repository">@Repository</a><br> <a href="http://twitter.com/Controller">@Controller</a><br> <a href="http://twitter.com/Autowired">@Autowired</a><br> <a href="http://twitter.com/Qualifier">@Qualifier</a><br> <a href="http://twitter.com/Primary">@Primary</a><br> Circular dependency<br> How do you resolve circular dependency?<br> Spring Boot<br> Spring vs Spring Boot<br> What is <a href="http://twitter.com/SpringBootApplicatio">@SpringBootApplicatio</a>n?<br> What is auto-configuration?<br> Component scanning<br> How does Spring Boot application startup work?<br> application.properties vs application.yml<br> Profiles<br> Configuration properties<br> Externalized configuration<br> Actuator<br> Health endpoint<br> How do you expose application metrics?<br>Transactions<br> What is <a href="http://twitter.com/Transactional">@Transactional</a>?<br> How does <a href="http://twitter.com/Transactional">@Transactional</a> work internally?<br> Transaction propagation<br> Transaction isolation<br> Rollback rules<br> What happens when an exception occurs inside <a href="http://twitter.com/Transactional">@Transactional</a>?<br> Self-invocation problem with <a href="http://twitter.com/Transactional">@Transactional</a><br> Exception Handling<br> <a href="http://twitter.com/ControllerAdvice">@ControllerAdvice</a><br> <a href="http://twitter.com/ExceptionHandler">@ExceptionHandler</a><br> Global exception handling<br> How would you design a standard API error response?</p><h4><strong>5. Spring MVC / REST</strong></h4><p>Explain request flow in Spring Boot.<br> What is DispatcherServlet?<br> Controller → Service → Repository architecture<br> GET vs POST vs PUT vs PATCH<br> PUT vs PATCH<br> HTTP status codes<br> 200 vs 201 vs 204<br> 400 vs 401 vs 403 vs 404 vs 409 vs 500<br> REST principles<br> What is statelessness?<br> API versioning<br> Pagination<br> Filtering<br> Validation<br> <a href="http://twitter.com/Valid">@Valid</a><br> Idempotency<br> How would you make a payment API idempotent?<br> REST exception handling</p><h4><strong>6. JPA / Hibernate</strong></h4><p>JPA vs Hibernate<br> Entity lifecycle<br> Persistence Context<br> What is dirty checking?<br> First-level cache<br> Second-level cache<br> Lazy vs Eager loading<br> N+1 problem<br> How do you solve N+1?<br> JOIN FETCH<br> Entity relationships<br> One-to-One<br> One-to-Many<br> Many-to-One<br> Many-to-Many<br> mappedBy<br> Cascade types<br> CascadeType.ALL<br> orphanRemoval<br> JPQL<br> Criteria API<br> Composite key<br> <a href="http://twitter.com/EmbeddedId">@EmbeddedId</a> vs <a href="http://twitter.com/IdClass">@IdClass</a><br> Optimistic locking<br> Pessimistic locking<br> JPA transactions<br> How does Hibernate generate SQL?<br> How would you optimize a slow Hibernate query?</p><h4><strong>7. Microservices</strong></h4><p>Monolith vs Microservices<br> Advantages/disadvantages of microservices<br> Service-to-service communication<br> REST vs Kafka<br> Synchronous vs asynchronous communication<br> API Gateway<br> Service Discovery<br> OpenFeign<br> Centralized configuration<br> Circuit Breaker<br> Retry<br> Timeout<br> Bulkhead<br> Rate Limiting<br> Idempotency<br> Distributed transactions<br> Saga pattern<br> Database per service<br> Event-driven architecture<br> Centralized logging<br> Distributed tracing<br> Fault tolerance<br> How do you handle service failure?<br> How do you prevent cascading failures?<br> How do you handle duplicate requests?<br> How do you handle 1000 TPS?</p><p>Load Balancer → API Gateway → Microservice → Cache → DB → Kafka → scaling → failure handling → monitoring</p><h4>8. Kafka</h4><p>What is Kafka?<br> Kafka architecture<br> Producer<br> Consumer<br> Topic<br> Partition<br> Offset<br> Consumer Group<br> How does partitioning work?<br> How is ordering maintained?<br> Replication<br> Leader/follower<br> Producer acknowledgement<br> acks=0/1/all<br> At-most-once<br> At-least-once<br> Exactly-once<br> Consumer failure<br> Producer failure<br> Consumer lag<br> Retry<br> Dead Letter Topic<br> Duplicate messages<br> Idempotent consumer<br> Partition strategy<br> Kafka vs RabbitMQ<br> Kafka vs REST<br> When would you NOT use Kafka?</p><h4>9. Redis</h4><p>Why Redis?<br> Redis vs database<br> Cache-aside pattern<br> Cache hit vs cache miss<br> TTL<br> Eviction policies<br> Cache invalidation<br> Cache stampede<br> What happens if Redis goes down?<br> Redis data structures<br> Distributed locking<br> How would you cache frequently accessed data?<br> How would you handle 1,000 requests/sec using Redis?</p><h4>10. SQL</h4><p>Queries<br> INNER JOIN<br> LEFT JOIN<br> RIGHT JOIN<br> GROUP BY<br> HAVING<br> Subquery<br> EXISTS<br> Find duplicate records<br> Second highest salary<br> Nth highest salary<br> Top N per group<br> ROW_NUMBER<br> RANK<br> DENSE_RANK<br> Find employees with duplicate salary<br> Find department with highest salary<br> Database concepts<br> Index<br> Why use indexes?<br> Clustered vs non-clustered index<br> Composite index<br> Index column order<br> When can an index hurt performance?<br> Query optimization<br> Normalization<br> Denormalization<br> ACID<br> Transaction<br> Isolation levels<br> Deadlock</p><h4>11. Your Project</h4><p>This deserves its own preparation, not just one section of Java.</p><p>Prepare these questions extremely well:</p><p>Explain your project.<br> Explain the architecture.<br> What exactly does your application do?<br> What is your role?<br> What are your day-to-day responsibilities?<br> What APIs have you worked on?<br> Which Java/Spring technologies do you use?<br> Where did you use Redis?<br> Why did you choose Redis?<br> What data did you cache?<br> What happens when Redis is unavailable?<br> Where did you use Kafka/RabbitMQ?<br> Why asynchronous communication?<br> How do you handle duplicate messages?<br> How do you handle transactions?<br> How do you handle failures?<br> How do you debug production issues?<br> Tell me about a production issue you solved.<br> Tell me about a performance issue you solved.<br> How do you monitor your application?<br> How do you test your APIs?<br> How do you handle high TPS?<br> How do you deploy your application?<br> What was the most challenging technical problem you faced?<br> What improvement did you personally make?</p><p>This section can make a huge difference in a Senior-level interview.</p><h4>12. Security / JWT</h4><p>Authentication vs Authorization<br> JWT<br> JWT structure<br> Access token vs refresh token<br> JWT flow<br> Spring Security filter chain<br> How does authentication happen?<br> How does authorization happen?<br> Where is JWT validated?<br> What happens if JWT expires?<br> OAuth2 basics<br> How would you secure a REST API?</p><p>Your JWT explanation was already one of your stronger areas, so maintain that strength.</p><h4>13. Docker / Kubernetes</h4><p>Docker<br> What is Docker?<br> Image vs Container<br> Dockerfile<br> Docker Compose<br> Why use containers?<br> How do you containerize Spring Boot?<br> Kubernetes<br> What is Kubernetes?<br> Pod<br> Deployment<br> Service<br> ConfigMap<br> Secret<br> Replica<br> Horizontal scaling<br> Liveness probe<br> Readiness probe<br> How would you deploy Spring Boot on Kubernetes?<br> Docker vs Kubernetes</p><h4>14. System Design</h4><p>Framework</p><p>For every design:</p><p>Requirements → Scale → APIs → DB → Architecture → Communication → Cache → Kafka → HA → Failure Handling → Monitoring</p><p>Practice these<br> Design Stock Trading System<br> Design Citizen-facing High Traffic Application<br> Design Order Management System<br> Design URL Shortener<br> Design Notification System<br> Design Payment System<br> Design Rate Limiter<br> Concepts<br> Horizontal scaling<br> Load balancing<br> API Gateway<br> Database selection<br> Database indexing<br> Caching<br> Kafka<br> Synchronous vs asynchronous<br> Fault tolerance<br> Retry<br> Timeout<br> Circuit breaker<br> High availability<br> Bottleneck identification<br> Monitoring</p><h4>15. LLD</h4><p>SOLID principles<br> Interface vs abstract class<br> Composition vs inheritance<br> Factory pattern<br> Strategy pattern<br> Observer pattern<br> Singleton pattern<br> Basic class design<br> Entity design<br> API design</p><p>You don’t need to spend weeks on design patterns.</p><p>Understand why and when each pattern is used.</p><h4>16. DSA</h4><p>Priority<br> Arrays<br> Strings<br> HashMap / HashSet<br> Two Sum<br> Two Pointers<br> Sliding Window<br> Stack<br> Queue<br> LinkedList<br> Binary Search<br> Sorting<br> Kadane<br> Merge Sorted Arrays<br> Remove Duplicates<br> Stock Buy/Sell<br> Balanced Parentheses<br> Binary Tree<br> BST<br> BFS<br> DFS<br> Heap<br> Basic DP</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db38fd1005b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Limitations of using Stream API in code.]]></title>
            <link>https://medium.com/@dev_RV/limitations-of-using-stream-api-in-code-78034939c8b0?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/78034939c8b0</guid>
            <category><![CDATA[java-stream-api]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 18:11:24 GMT</pubDate>
            <atom:updated>2026-09-09T18:11:24.066Z</atom:updated>
            <content:encoded><![CDATA[<p>While the <strong>Java 8 Stream API</strong> revolutionized the language by introducing a functional, declarative approach to processing collections, it comes with several architectural and functional limitations. [</p><p>1. No Native Support for Checked Exceptions</p><p>Stream operations — such as map and filter—do not inherently support checked exceptions within lambda expressions. If your pipeline invokes logic that throws a checked exception (e.g., IOException or SQLException), you are forced to wrap it in a verbose try-catch block, convert it into an unchecked exception, or use custom wrappers.</p><p><em>“Stream operations (e.g., map, filter) don’t support checked exceptions in lambda expressions, requiring try-catch blocks or wrapper methods, which can clutter code.”</em></p><p>2. Streams Cannot Be Reused</p><p>A stream can only be <strong>consumed once</strong>. Once a terminal operation (like collect(), sum(), or forEach()) is executed, the stream is closed. Attempting to traverse or reuse the same stream object will result in an IllegalStateException. If you need to perform multiple operations on the same data set, you must generate a new stream instance from the underlying data source every time.</p><p>3. Lack of Extensibility (No Custom Intermediate Operators)</p><p>In Java 8, the intermediate operations provided by the API (such as filter(), map(), and flatMap()) are <strong>fixed and cannot be extended</strong>. You cannot natively create custom intermediate logic—like processing records in batches or stateful windowing—without code duplication or relying on complex workarounds.<br><em>(Note: To fix this exact limitation, Java introduced &quot;Stream Gatherers&quot; as a preview in JDK 21 and finalized them in JDK 24, allowing custom intermediate operators.)</em></p><p>4. Inefficiencies with I/O-Bound Tasks and Shared Threads</p><p>Parallel streams in Java 8 natively utilize a shared, global <strong>ForkJoinPool</strong>. This design works well for CPU-bound computations, but it is <strong>not optimally designed for concurrent execution of I/O-bound tasks</strong>. If a parallel stream handles slow network requests or database calls, it can block threads in the common pool, inadvertently throttling other unrelated parallel streams running across your application.</p><p>5. Performance Overhead for Simple Iterations</p><p>For basic or small datasets, streams are generally <strong>slower than vanilla loops</strong> (like the traditional for or for-each statements). The process of setting up the pipeline requires object creation, lambda invocations, and boxing/unboxing overhead, which introduces a structural runtime cost.</p><p>6. No Direct Element Access or Modification</p><p>Unlike standard collection data structures, a stream <strong>does not store data</strong> in memory. Because of this, you cannot randomly access an item by its index or directly manipulate elements at a specific position within the stream layout. You can only pass functional descriptions of aggregate computations to be executed on the source data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78034939c8b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stream API]]></title>
            <link>https://medium.com/@dev_RV/stream-api-2c3c6ee646c4?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c3c6ee646c4</guid>
            <category><![CDATA[java-stream-api]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 12:57:28 GMT</pubDate>
            <atom:updated>2026-06-27T12:57:28.338Z</atom:updated>
            <content:encoded><![CDATA[<p>Most asked questions from Stream for Interviews.(Must Know)</p><p><em>1.second largest element</em></p><p><em>=&gt;List&lt;Integer&gt; numbers = List.of(1, 2, 3, 4, 5);<br>int secondLargest = numbers.stream()<br> .sorted(Comparator.reverseOrder())<br> .skip(1)<br> .findFirst()<br> .orElse(0);<br>System.out.println(“Second Largest: “ + secondLargest);</em></p><p>2.sort employees by salary</p><p><em>=&gt;</em>emp.stream()<br> .sorted(Comparator.comparing(Employee::getSalary).reversed())<br> .collect(Collectors.toList());</p><p>3.second highest salary</p><p><em>=&gt;</em>emp.stream()<br> .sorted(Comparator.comparing(Employee::getSalary).reversed())<br> .skip(1).<br> .findFirst()<br> .collect(Collectors.toList());</p><p>4.group employees by department</p><p><em>=&gt;</em>emp.stream()<br> .collect(Collectors.groupingBy(Employee::getDepartment));</p><p>5.count frequency of chars //imp</p><p><em>=&gt;</em>list.stream()<br> .flatMapToInt(String::chars)<br> .mapToObj(c -&gt; (char) c)<br> .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));</p><p>6.remove duplicates</p><p><em>=&gt;</em>list.stream()<br> .distinct()<br> .collect(Collectors.toList());</p><p>7.first non-repeating char //Imp</p><p><em>=&gt;</em>list.stream.<br> flatMapToInt(String::chars)<br> .mapToObj(c -&gt; (char) c)<br> .collect(Collectors.groupingBy(Function.identity(), LinkedHashMap::new, Collectors.counting()))<br> .entrySet()<br> .stream()<br> .filter(entry -&gt; entry.getValue() == 1)<br> .map(Map.Entry::getKey)<br> .findFirst()<br> .orElse(null);</p><p>8.flatten nested lists</p><p><em>=&gt;</em>list.stream()<br> .flatMap(Collection::stream)<br> .collect(Collectors.toList());</p><p>9.even/odd partitioning</p><p><em>=&gt;</em>list.stream()<br> .collect(Collectors.partitioningBy(num -&gt; num % 2 == 0));</p><p>10.max/min salary</p><p><em>=&gt;</em>list.stream()<br> .max(Comparator.comparing(Employee::getSalary))<br> .orElse(null);</p><p><em>=&gt;</em>list.stream()<br> .min(Comparator.comparing(Employee::getSalary))<br> .orElse(null);</p><p>11.convert list to map</p><p><em>=&gt;</em>list.stream()<br> .collect(Collectors.toMap(Employee::getId, Function.identity()));</p><p>12.Filter employees by salary</p><p><em>=&gt;</em>list.stream()<br> .filter(emp -&gt; emp.getSalary() &gt; 50000)<br> .collect(Collectors.toList());</p><p>13.Group by department</p><p><em>=&gt;</em>list.stream()<br> .collect(Collectors.groupingBy(Employee::getDepartment));<br> <br>14.Find duplicate elements //imp</p><p><em>=&gt;</em>list.stream()<br> .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))<br> .entrySet()<br> .stream()<br> .filter(entry -&gt; entry.getValue() &gt; 1)<br> .map(Map.Entry::getKey)<br> .collect(Collectors.toList());<br> <br> <br> <br>15.Count frequency of words</p><p><em>=&gt;</em>list.stream()<br> .collect(Collectors.groupingBy(x-&gt;x, Collectors.counting()));<br> <br>16.Sort objects</p><p><em>=&gt;</em>list.stream()<br> .sorted(Comparator.comparing(Employee::getSalary))<br> .collect(Collectors.toList());<br> <br> <br>17.Top N highest salaries</p><p><em>=&gt;</em>list.stream()<br> .sorted(Comparator.comparing(Employee::getSalary).reversed())<br> .limit(N)<br> .collect(Collectors.toList());</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c3c6ee646c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[21 days Inteview Revision topics for Java Backend Developer-]]></title>
            <link>https://medium.com/@dev_RV/21-days-inteview-revision-topics-for-java-backend-developer-4696336442d4?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/4696336442d4</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 17:28:36 GMT</pubDate>
            <atom:updated>2025-12-27T17:47:56.368Z</atom:updated>
            <content:encoded><![CDATA[<p>These topics are must for Java interview which I have curated by giving 10+ interviews, and in each interview these are the must topics and question asked.</p><p><strong>Don’t miss to review the questions asked specifically.</strong></p><h4>MUST-HAVE DSA TOPICS</h4><p>(Practice 3–4 problems for each pattern) + (pattern recognition by solving patternwise approach)</p><ul><li>Arrays &amp; Strings</li><li>HashMap / HashSet</li><li>Two pointers</li><li>Sliding window</li><li>Stack and Queue</li><li>Basic recursion</li><li>Binary search</li><li>Linked List basics</li></ul><h3>✅ WEEK 1 (Core Java + Java 8)</h3><p><strong>Day 1:</strong> OOP concepts (deep)<br> <strong>Day 2:</strong> Collections (HashMap, ConcurrentHashMap)<br> <strong>Day 3:</strong> Java 8 (Streams, Lambda, Optional)<br> <strong>Day 4:</strong> Exception handling + JVM basics<br> <strong>Day 5:</strong> Multithreading (Thread vs Executor, locks)<br> <strong>Day 6:</strong> Coding (Strings, Arrays)<br> <strong>Day 7:</strong> Revision + mock answers</p><h3>✅ WEEK 2 (Spring &amp; Spring Boot)</h3><p><strong>Day 8:</strong> Spring Core (IOC, DI, Bean lifecycle)<br> <strong>Day 9:</strong> Annotations, Autowiring, Scopes<br> <strong>Day 10:</strong> Spring Boot internals &amp; auto-config<br> <strong>Day 11:</strong> REST APIs (best practices, status codes)<br> <strong>Day 12:</strong> Exception handling, validation, logging<br> <strong>Day 13:</strong> Coding + project discussion<br> <strong>Day 14:</strong> Full revision</p><h3>✅ WEEK 3 (Microservices + SQL + Design)</h3><p><strong>Day 15:</strong> Microservices basics &amp; communication<br> <strong>Day 16:</strong> Feign, RestTemplate, WebClient<br> <strong>Day 17:</strong> SQL (joins, indexing, optimization)<br> <strong>Day 18:</strong> System design (scaling, caching, DB)<br> <strong>Day 19:</strong> Security basics (JWT, OAuth overview)<br> <strong>Day 20:</strong> Mock interview (self or friend)<br> <strong>Day 21 :</strong> Weak areas + resume final touch</p><h3>🔹 Core Java</h3><ul><li>Explain the differences between <strong>HashMap, ConcurrentHashMap, and Hashtable</strong>.</li><li>How does <strong>Java Memory Model</strong> work? What are <strong>heap vs stack vs metaspace</strong>?</li><li>What is the difference between <strong>final, finally, and finalize</strong>?</li><li>How does <strong>Garbage Collection (GC)</strong> work in Java? What are <strong>minor GC, major GC</strong>?</li><li>Explain <strong>synchronized vs ReentrantLock vs volatile</strong>.</li><li>How does <strong>ExecutorService / ThreadPool</strong> work?</li><li>What is <strong>Java Stream API</strong>? Advantages over traditional iteration?</li><li>Deep dive into <strong>equals() and hashCode()</strong> contract.</li><li>How does <strong>Optional</strong> help avoid null pointer exceptions?</li></ul><h3>🔹 Spring &amp; Spring Boot</h3><ul><li>Difference between <strong>Spring vs Spring Boot</strong>?</li><li>How does <strong>Dependency Injection</strong> work in Spring?</li><li>What are <strong>Bean Scopes</strong> in Spring?</li><li>Explain the <strong>Spring Bean lifecycle</strong>.</li><li>Difference between <strong>@Component, @Service, @Repository, @Controller</strong>.</li><li>What is the use of <strong>@Transactional</strong>? How does Spring manage transactions internally?</li><li>Explain <strong>Spring Boot Auto-Configuration</strong>.</li><li>How does <strong>Spring Security</strong> handle authentication and authorization?</li><li>How do you configure <strong>profiles</strong> in Spring Boot?</li><li>How do you handle <strong>application properties and secrets management</strong>?</li></ul><h3>🔹 Microservices</h3><ul><li>What are <strong>microservices</strong>? How are they different from monoliths?</li><li>How do microservices communicate with each other? (REST, gRPC, messaging)</li><li>How do you implement <strong>service discovery</strong>? (Eureka, Consul, Kubernetes)</li><li>What is an <strong>API Gateway</strong>? Why is it used?</li><li>How do you handle <strong>configuration management</strong> in microservices? (Spring Cloud Config, Vault)</li><li>How do you ensure <strong>fault tolerance</strong>? (Circuit Breaker — Resilience4j, Hystrix)</li><li>What is <strong>distributed logging</strong>? How do you implement it? (ELK stack, Sleuth, Zipkin)</li><li>Explain <strong>event-driven microservices</strong>.</li><li>How do you handle <strong>database per service</strong>? How do you ensure <strong>data consistency</strong> (saga, 2PC)?</li><li>How do you handle <strong>asynchronous communication</strong> (Kafka, RabbitMQ)?</li></ul><h3>🔹 System Design &amp; Architecture</h3><ul><li>Design a <strong>URL Shortener</strong> or <strong>Ride Booking System</strong>.</li><li>How would you design a <strong>highly scalable e-commerce application</strong> backend?</li><li>How do you ensure <strong>horizontal scalability</strong> in microservices?</li><li>Explain <strong>CQRS and Event Sourcing</strong>.</li><li>Difference between <strong>monolithic vs SOA vs microservices</strong>.</li><li>How do you handle <strong>caching</strong> (Redis, Hazelcast)?</li><li>How do you handle <strong>rate limiting</strong> and <strong>throttling</strong> in APIs?</li></ul><h3>Cloud (AWS / Azure / GCP — basic level expected)</h3><ul><li>What is the difference between <strong>IaaS, PaaS, SaaS</strong>?</li><li>Have you deployed microservices to <strong>AWS ECS / EKS / Lambda</strong> or Azure App Services?</li><li>How do you use <strong>S3 / Blob Storage</strong> for file handling?</li><li>Explain <strong>API Gateway and Load Balancer</strong> differences.</li><li>What is <strong>auto-scaling</strong>? How is it achieved?</li><li>How do you manage <strong>secrets and configurations</strong> in the cloud? (AWS Secrets Manager, Azure Key Vault)</li><li>Explain <strong>CI/CD pipelines</strong> for microservice deployment.</li></ul><h3>🔹 Database &amp; Persistence</h3><ul><li>Difference between <strong>JPA vs Hibernate</strong>?</li><li>What is the <strong>N+1 problem</strong> in Hibernate? How to avoid it?</li><li>How do you implement <strong>pagination</strong> in JPA?</li><li>Difference between <strong>lazy loading and eager loading</strong>.</li><li>What is <strong>optimistic vs pessimistic locking</strong>?</li><li>How do you design <strong>schema for microservices</strong>?</li><li>Explain <strong>SQL vs NoSQL</strong> databases. When to choose each?</li></ul><h3>🔹 Advanced Topics</h3><ul><li>How do you handle <strong>JWT-based authentication</strong> in microservices?</li><li>What is <strong>OAuth2.0</strong> and how does it work with Spring Security?</li><li>How do you monitor microservices? (Prometheus, Grafana, ELK)</li><li>How do you implement <strong>blue-green deployment</strong> or <strong>canary release</strong>?</li><li>How do you secure <strong>REST APIs</strong>? (HTTPS, CORS, CSRF, API tokens)</li><li>What are <strong>design patterns</strong> you have applied in your projects? (Singleton, Factory, Builder, Observer, Strategy, etc.)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4696336442d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview important — SQL Questions]]></title>
            <link>https://medium.com/@dev_RV/interview-important-sql-questions-2c74254d77b1?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c74254d77b1</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 14:39:38 GMT</pubDate>
            <atom:updated>2025-11-16T14:39:38.926Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interview important — SQL Questions</h3><h3>📌 1. SQL (Must-Have)</h3><p>You should be confident in:</p><ul><li><strong>CRUD operations</strong> (SELECT, INSERT, UPDATE, DELETE)</li><li><strong>Joins</strong> (INNER, LEFT, RIGHT, FULL, SELF, CROSS).</li><li><strong>Aggregate functions</strong> (COUNT, SUM, AVG, MAX, MIN).</li><li><strong>GROUP BY / HAVING</strong> (common interview favorite).</li><li><strong>Subqueries, EXISTS, IN, ANY, ALL</strong>.</li><li><strong>Set operations</strong> (UNION, INTERSECT, EXCEPT).</li><li><strong>Sorting &amp; Pagination</strong> (ORDER BY, LIMIT/OFFSET, ROWNUM).</li><li><strong>Window functions</strong> (ROW_NUMBER, RANK, DENSE_RANK, PARTITION BY).</li></ul><p>👉 Expect coding rounds where you’ll be asked to write SQL queries.</p><h3>📌 2. Database Design &amp; Normalization</h3><ul><li><strong>1NF, 2NF, 3NF</strong> (what they mean, when to use).</li><li><strong>Primary Key, Foreign Key, Composite Key</strong>.</li><li><strong>Indexes</strong> — clustered vs non-clustered, pros/cons.</li><li><strong>Entity-Relationship basics</strong>.</li><li><strong>Denormalization &amp; trade-offs</strong> (often in system design rounds).</li></ul><h3>📌 3. Performance &amp; Query Optimization</h3><ul><li>How <strong>indexes</strong> affect query performance.</li><li>What is <strong>EXPLAIN plan</strong> and how to analyze queries.</li><li>Common issues like <strong>N+1 queries</strong> (especially in Hibernate/JPA).</li><li>How to handle <strong>large datasets efficiently</strong> (pagination, batch inserts/updates).</li></ul><h3>📌 4. Transactions &amp; Concurrency</h3><ul><li><strong>ACID properties</strong>.</li><li><strong>Transaction isolation levels</strong> (Read Uncommitted, Read Committed, Repeatable Read, Serializable).</li><li><strong>Deadlocks &amp; locks</strong> — how they happen, how to avoid.</li><li><strong>Optimistic vs Pessimistic locking</strong> (common in Hibernate/JPA).</li></ul><h3>📌 5. Practical Java + DB Integration</h3><ul><li><strong>JDBC basics</strong> — PreparedStatement, ResultSet, connection pooling.</li><li><strong>ORM (Hibernate/JPA)</strong> — mappings, @OneToMany, @ManyToMany, lazy vs eager loading.</li><li><strong>Spring Data JPA</strong> — repositories, @Query, @Modifying.</li><li>Handling <strong>transactions in Spring</strong> (@Transactional).</li><li><strong>Caching strategies</strong> (e.g., Hibernate 1st &amp; 2nd level cache).</li></ul><h3>📌 6. System Design Level (for senior interviews)</h3><ul><li>Choosing between <strong>SQL vs NoSQL</strong> (when to use what).</li><li><strong>Sharding, replication, partitioning basics</strong>.</li><li><strong>Eventual consistency vs strong consistency</strong>.</li><li><strong>Read-heavy vs write-heavy optimization strategies</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c74254d77b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Asked SpringBoot and Microservices Questions in Interview —]]></title>
            <link>https://medium.com/@dev_RV/most-asked-springboot-and-microservices-questions-in-interview-aaf1a4924c98?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf1a4924c98</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Tue, 05 Aug 2025 10:26:34 GMT</pubDate>
            <atom:updated>2025-08-05T10:26:34.289Z</atom:updated>
            <content:encoded><![CDATA[<p>This post contains random frequently asked interview question -</p><p>FetchType.LAZY is a JPA (Java Persistence API) enum value that indicates that the associated entities or collections should be fetched lazily, meaning they will be loaded only when they are actually needed. This can help improve performance by reducing the amount of data that is loaded from the database.</p><p>FetchType.EAGER is another JPA enum value.</p><p>When you use FetchType.EAGER, the associated entities or collections are fetched immediately, along with the parent entity. This means that all the related data is loaded from the database in a single query, which can be useful when you know you&#39;ll need that data right away.</p><p>However, be aware that eager loading can lead to performance issues if you’re dealing with large amounts of data or complex relationships, since it can result in a lot of data being loaded unnecessarily.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf1a4924c98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Java Really old or gone ?]]></title>
            <link>https://medium.com/@dev_RV/is-java-really-old-or-gone-7cf3773dfb2f?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cf3773dfb2f</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[netflix]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Sat, 05 Apr 2025 18:47:00 GMT</pubDate>
            <atom:updated>2025-04-05T18:47:00.291Z</atom:updated>
            <content:encoded><![CDATA[<h3>Is Java Really old or gone ?</h3><p>See the Reality → “Netflix is all powered by Java”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q3bJdssmw6iddgd7" /><figcaption>Photo by <a href="https://unsplash.com/@ozvargas?utm_source=medium&amp;utm_medium=referral">Oscar Vargas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*OJ7yu_FrF9kXI4zK" /></figure><h3>✅ Where Netflix uses Java:</h3><ul><li><strong>Backend services / Microservices:</strong><br> Netflix uses <strong>Java with Spring Boot and Spring Cloud</strong> for many of its core services.</li><li><strong>Frameworks:</strong><br> Netflix has open-sourced several Java-based tools and frameworks like:</li><li><strong>Hystrix</strong> (circuit breaker, now deprecated)</li><li><strong>Eureka</strong> (service discovery)</li><li><strong>Zuul</strong> (API gateway, earlier version in Java)</li><li><strong>Archaius</strong> (configuration management)</li><li><strong>JVM-based scalability:</strong><br> Java runs well on the JVM, which allows Netflix to scale microservices efficiently.</li></ul><p>Not Just Netflix , Amzon even huge banking projects are running on Java .</p><p>→ Your UPI transaction? Java.<br>→ Your airline ticket? Java.<br>→ Netflix binge? Java again.</p><p>Companies don’t care what’s trending. <br>They care about what works at scale. <br>And with Java? It works.</p><h4>Java is still a dominant player in the tech world, especially for large-scale, enterprise-level applications.</h4><h3>🌍 1. LinkedIn</h3><ul><li><strong>Primary Language:</strong> Java</li><li><strong>Tech Stack:</strong> Java, Scala, Kafka, Voldemort, and Play framework (Scala-based)</li><li><strong>Use Case:</strong> LinkedIn uses Java extensively for backend services, performance-heavy features, and real-time data pipelines.</li></ul><h3>💳 2. PayPal</h3><ul><li><strong>Primary Language:</strong> Java</li><li><strong>Use Case:</strong> Handles millions of secure financial transactions daily using Java-based services and APIs.</li></ul><h3>📦 3. Amazon (Backend Services)</h3><ul><li>While not <em>entirely</em> Java, <strong>many internal microservices at Amazon are Java-based</strong>.</li><li>Use of <strong>Java + Spring + AWS-native services</strong>.</li><li>Amazon-owned services like <strong>Kindle backend systems</strong> are heavily reliant on Java.</li></ul><h3>🎮 4. Minecraft</h3><ul><li><strong>Client and Server Language:</strong> Java (for the original version)</li></ul><p>Still one of the <strong>most popular games worldwide</strong>, and the <strong>Java Edition</strong> is the most mod-friendly and educational version.</p><h3>🎬 5. Netflix</h3><ul><li>Already discussed: uses Java extensively in backend microservices.</li></ul><h3>🏦 6. Banks &amp; Financial Systems (JPMorgan Chase, Citi, etc.)</h3><ul><li>Most <strong>banking systems</strong> still run critical infrastructure on <strong>Java</strong>.</li><li>Legacy and modern systems in <strong>core banking</strong>, <strong>trading platforms</strong>, <strong>risk assessment tools</strong>, and more.</li><li>Apps like <strong>Murex</strong>, <strong>Calypso</strong>, and <strong>Flexcube</strong> are Java-based.</li></ul><h3>📈 7. Twitter (Historically)</h3><ul><li>Initially built in Ruby, later moved many core backend services to <strong>Java + Scala</strong> for performance reasons.</li></ul><h3>🛒 8. eBay</h3><p>Uses Java for core business logic, backend services, and large-scale data processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cf3773dfb2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Pattern for In]]></title>
            <link>https://medium.com/@dev_RV/microservices-pattern-for-in-270ff2e8fe27?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/270ff2e8fe27</guid>
            <category><![CDATA[saga]]></category>
            <category><![CDATA[strangler-pattern]]></category>
            <category><![CDATA[microservices-pattern]]></category>
            <category><![CDATA[cqrs]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 15:34:14 GMT</pubDate>
            <atom:updated>2025-02-06T15:34:14.406Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices Pattern for Interviews</h3><h3>Decomposition pattern in microservices</h3><p>Decomposition is a core principle in microservices architecture, ensuring that an application is broken down into smaller, independent services. There are several decomposition patterns used to achieve this, each serving a different purpose.</p><h3>1. Decomposition by Business Capability</h3><ul><li>Splits services based on business functionalities.</li><li>Each service corresponds to a distinct business capability (e.g., Billing, Order Management, Inventory).</li><li>Encourages domain-driven design (DDD).</li></ul><p>✅ <strong>Pros</strong>: Aligns with business needs, promotes scalability.<br>❌ <strong>Cons</strong>: Requires deep domain knowledge.</p><h3>2. Decomposition by Subdomain (DDD)</h3><ul><li>Uses Domain-Driven Design (DDD) principles to split services based on bounded contexts.</li><li>Each service owns its data and logic for a specific domain (e.g., Payment, Shipment).</li></ul><p>✅ <strong>Pros</strong>: Ensures clear ownership and loose coupling.<br>❌ <strong>Cons</strong>: Requires extensive domain modeling.</p><h3>3. Decomposition by Transactions</h3><ul><li>Services are split based on transactional boundaries.</li><li>Avoids distributed transactions, ensuring consistency using eventual consistency.</li></ul><p>✅ <strong>Pros</strong>: Prevents complex distributed transactions.<br>❌ <strong>Cons</strong>: Can introduce latency due to eventual consistency.</p><h3>4. Decomposition by Data Ownership</h3><ul><li>Services are defined based on ownership of a specific set of data.</li><li>Each service maintains its own database (avoiding monolithic databases).</li></ul><p>✅ <strong>Pros</strong>: Improves autonomy and scalability.<br>❌ <strong>Cons</strong>: Introduces complexity in data synchronization.</p><h3>5. Decomposition by Team Structure (Conway’s Law)</h3><ul><li>Services are structured based on team organization (e.g., separate teams for user, payment, and product).</li><li>Works well in large organizations following DevOps practices.</li></ul><p>✅ <strong>Pros</strong>: Improves development efficiency.<br>❌ <strong>Cons</strong>: Can lead to misaligned service boundaries.</p><h3>6. Decomposition by Strangler Pattern (Migration)</h3><ul><li>Used for migrating from monolith to microservices gradually.</li><li>New functionality is built as microservices while the monolith is slowly replaced.</li></ul><p>✅ <strong>Pros</strong>: Enables phased migration without system downtime.<br>❌ <strong>Cons</strong>: Requires careful monitoring to avoid inconsistencies.</p><h4>Choosing the Right Decomposition Strategy</h4><p>The right approach depends on:</p><ul><li>Business requirements.</li><li>Domain complexity.</li><li>Team structure.</li><li>Performance and scalability needs.</li></ul><p>_________________________________________________________________</p><h3>Strangler Pattern</h3><p><strong>Strangler Pattern</strong> → Refactoring application from -&gt; <strong>Monolithic → Microservices</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yB8gzIfgB_3hXXoi" /></figure><ul><li>A <strong>Monolithic</strong> system is handling requests.</li><li>A <strong>Controller</strong> is introduced to route API traffic.</li><li>API traffic is gradually moved from the Monolith to Microservices (<strong>S1, S2, S3, S4</strong>).</li><li>Over time, the Monolithic system becomes obsolete, and Microservices become independent.</li></ul><p>“While converting an application from monolithic to microservices, it can’t be done all at once. We allocate traffic from the monolithic system to microservices and keep gradually increasing it until it reaches independence.”</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>Saga Pattern in Microservices</h3><p>The <strong>Saga pattern</strong> is a design pattern used to maintain <strong>data consistency</strong> across multiple microservices in a <strong>distributed system</strong> without using distributed transactions (2PC). Instead of a single transaction, it uses a sequence of local transactions that communicate through <strong>events</strong> or <strong>orchestration</strong>.</p><h3>Types of Saga Pattern</h3><h3>1. Choreography-Based Saga</h3><ul><li>Each service listens for events and performs actions <strong>autonomously</strong>.</li><li>After completing its task, it <strong>emits an event</strong> that triggers the next service in the flow.</li></ul><p>✅ <strong>Pros</strong>:<br>✔ No centralized coordinator → Simpler for small workflows.<br>✔ Loosely coupled microservices.</p><p>❌ <strong>Cons</strong>:<br>✘ Hard to manage complex workflows.<br>✘ Debugging is difficult due to many event dependencies.</p><p>📌 <strong>Example</strong>:</p><ol><li><strong>Order Service</strong> → Places an order → Emits event OrderCreated.</li><li><strong>Payment Service</strong> → Processes payment → Emits event PaymentProcessed.</li><li><strong>Inventory Service</strong> → Updates stock → Emits event StockUpdated.</li></ol><h3>2. Orchestration-Based Saga</h3><ul><li>A <strong>centralized “Saga Orchestrator”</strong> manages the workflow.</li><li>The orchestrator calls each microservice and waits for its response before moving to the next step.</li></ul><p>✅ <strong>Pros</strong>:<br>✔ Easier to manage and debug complex workflows.<br>✔ Clear control over the process.</p><p>❌ <strong>Cons</strong>:<br>✘ Introduces a single point of failure (orchestrator).<br>✘ Higher latency compared to choreography.</p><p>📌 <strong>Example</strong>:</p><ol><li><strong>Order Service</strong> sends a request to the <strong>Saga Orchestrator</strong>.</li><li>The <strong>Orchestrator</strong> calls the <strong>Payment Service</strong>.</li><li>If successful, it calls the <strong>Inventory Service</strong>.</li><li>If any step fails, it triggers a compensating transaction.</li></ol><h3>Error Handling in Saga (Compensating Transactions)</h3><p>Since transactions are <strong>distributed</strong>, failures must be handled properly using <strong>compensating actions</strong>.</p><p>📌 <strong>Example</strong>:</p><ul><li>If payment fails → <strong>Order Service cancels the order</strong>.</li><li>If inventory update fails → <strong>Payment is refunded</strong>.</li></ul><h3>When to Use the Saga Pattern?</h3><p>✅ For distributed systems requiring <strong>eventual consistency</strong>.<br>✅ When transactions span multiple services and need rollback mechanisms.<br>✅ Suitable for <strong>e-commerce, banking, and logistics</strong> systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4VgonKr884TI7nm9" /></figure><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>CQRS</h3><p>Command Query Responsibility Segregation (CQRS) is a software design pattern that separates read and write operations for a data store. The goal of CQRS is to improve the performance, security, and scalability of an application.</p><p><em>In simple understanding , it solved the purpose of query join which can’t be done in microservices unlike monolith.</em></p><h3>Problem</h3><p>How to implement a query that retrieves data from multiple services in a microservice architecture?</p><h3>Solution</h3><p>Define a view database, which is a read-only ‘replica’ that is designed specifically to support that query, or a group related queries. The application keeps the database up to date by subscribing to events published by the service that own the data. The type of database and its schema are optimized for the query or queries. It’s often a NoSQL database, such as a document database or a key-value store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/0*GHVmWRFd3KM8tL_d.png" /></figure><p>_________________________________________________________________</p><p>…to be continued</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=270ff2e8fe27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resiliency4j (Usage of Circuit Breaker Pattern Retry Pattern in Microservices)]]></title>
            <link>https://medium.com/@dev_RV/resiliency4j-usage-of-circuit-breaker-pattern-retry-pattern-in-microservices-3b0934edcf14?source=rss-8ff31e513e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b0934edcf14</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[resilience4j]]></category>
            <dc:creator><![CDATA[Ravi Pandey]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 13:42:28 GMT</pubDate>
            <atom:updated>2025-02-06T13:42:28.462Z</atom:updated>
            <content:encoded><![CDATA[<h3>Resiliency Using Resilience4j</h3><p><strong>Resilience4j</strong> is a lightweight fault-tolerance library designed for <strong>functional programming</strong>. It offers the following patterns for increasing fault tolerance due to network problems or failures of any of the multiple services:</p><h3>1. Circuit Breaker</h3><ul><li>Used to stop making requests when a service invoked is failing.</li></ul><h3>2. Fallback</h3><ul><li>Provides alternative paths to failing requests.</li></ul><h3>3. Retry</h3><ul><li>Used to make another attempt when a service has temporarily failed.</li></ul><h3>4. Rate Limit</h3><ul><li>Limits the number of calls that a service receives in a given time.</li></ul><h3>5. Bulkhead</h3><ul><li>Limits the number of concurrent requests to a service to avoid overloading.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HmhOlvjUAjdD5Tw1" /></figure><p><strong>In Resilience4j, the circuit breaker is implemented via three states</strong></p><p>1️⃣ <strong>Closed</strong></p><ul><li>Initially, the circuit breaker starts with a closed status and allows client requests.</li><li>If the <strong>failure rate exceeds the threshold</strong>, the circuit breaker transitions to <strong>Open</strong>.</li></ul><p>2️⃣ <strong>Open</strong></p><ul><li>If the circuit breaker detects a threshold of failing requests, it will <strong>open</strong>, meaning it will <strong>reject all requests</strong> immediately.</li><li>After a <strong>wait duration</strong>, it transitions to <strong>Half-Open</strong> to test if the service has recovered.</li></ul><p>3️⃣ <strong>Half-Open</strong></p><ul><li>In this state, the system allows a limited number of requests.</li><li>If failures <strong>remain above the threshold</strong>, it transitions back to <strong>Open</strong>.</li><li>If failures <strong>drop below the threshold</strong>, it transitions back to <strong>Closed</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LGXSIhNEjnXwlHhL" /></figure><p>The <strong>Circuit Breaker</strong> and <strong>Retry</strong> patterns are both resilience strategies in microservices architecture, but they serve different purposes. Let’s go through both with a diagram and explanation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZzGQfcUbjSV5zjKH" /></figure><h3><strong>Retry Pattern:</strong></h3><p>1. Transient Failures:</p><p>- Scenario: Your system occasionally experiences transient failures due to temporary network issues, high load, or other intermittent problems.</p><p>2. External Service Dependencies:</p><p>- Scenario: Your application relies on external services, and these services may occasionally experience downtime or connectivity issues.</p><p>3. Idempotent Operations:</p><ul><li>Scenario: The failed operation is idempotent, meaning that repeating the operation multiple times does not have additional side effects.</li></ul><p>_________________________________________________________________</p><p>Client → Service B<br> ↓<br> Failure? → Retry 1 → Retry 2 → Retry N (Max Limit)<br> ↓<br> Success? → Proceed <br> Failure → Give up<br>_________________________________________________________________</p><h3><strong>Circuit Breaker Pattern:</strong></h3><ol><li>Protecting Downstream Services:</li></ol><p>- Scenario: Your system makes calls to downstream services, and a failure in one of those services can lead to cascading failures and increased load on the system.</p><p>2. Avoiding Overload:</p><p>- Scenario: During a system outage or degraded performance, constant retries can overwhelm the system and exacerbate the problem.</p><p>3. Fail-Fast Mechanism:</p><p>- Scenario: Rapid retries on a consistently failing operation may not be productive and can lead to increased latency.</p><p>- Use Case: A circuit breaker provides a fail-fast mechanism by quickly detecting a failing operation and preventing subsequent attempts for a configurable period.</p><p>4. Graceful Degradation:</p><p>- Scenario: In scenarios where some level of functionality can be maintained even when certain operations are unavailable or degraded.</p><p>____________________________________________________________</p><p>Client → Circuit Breaker → Service B<br> | <br> ↓ <br> Failure Threshold Exceeded <br> ↓ <br> Circuit Breaker Opens <br> ↓ <br> Fallback or Error Response <br> ↓ <br> After Timeout → Half-Open State → Success? → Close Circuit</p><p>____________________________________________________________</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*7tQWDfRcFS-Jh749KXvFDg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b0934edcf14" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>