YouTube2Text

30 Java & Spring Boot Scenario-Based Interview Questions | Real-World Production Problems | Part 1 — Transcript

by TechFestJava · 3,698 words · 591 segments · language en · Watch on YouTube

Full transcript

  1. 0:00If you are preparing for a senior Java
  2. 0:01developer, tech lead or a solution
  3. 0:03architect interview, there is something
  4. 0:05you need to understand. At this level,
  5. 0:08interviewers are usually not interested
  6. 0:10in hearing a textbook definition. They
  7. 0:12don't want you to simply tell them what
  8. 0:14at the rate transactional does or what
  9. 0:17an index is or what caching means.
  10. 0:19Instead, they are giving you a
  11. 0:21production problem. An API suddenly
  12. 0:23becomes slow, a payment get processed
  13. 0:25twice or one application instance
  14. 0:27crashes with out of memory error or a
  15. 0:30database query that was fast yesterday
  16. 0:33suddenly taking 10 seconds. These type
  17. 0:35of questions they will ask and then they
  18. 0:37ask you one simple question, what would
  19. 0:40you do? That's when the senior level
  20. 0:41thinking really matters. In this video,
  21. 0:44I'm going to walk through 30 real world
  22. 0:46scenario based interview questions
  23. 0:48covering Java, Spring Boot, Hibernate,
  24. 0:50PostgreSQL, Kafka, transactions,
  25. 0:52concurrency, performance and some
  26. 0:54architecture related questions as well.
  27. 0:56And for every scenario, I will explain
  28. 0:58not just what solution to use, but more
  29. 1:01importantly, how a senior engineer would
  30. 1:03investigate the problem and why that
  31. 1:05solution should be chosen. Let's start.
  32. 1:07Imagine your Spring Boot API normally
  33. 1:10responded in around 200 milliseconds,
  34. 1:12but suddenly in a production the
  35. 1:13response time increased between 5 to 10
  36. 1:16seconds. Now CPU looks completely
  37. 1:18normal, but your database connection
  38. 1:20pool is exhausted. Now interviewer is
  39. 1:22asking, what would you investigate first
  40. 1:24in this? Before giving an answer, jump
  41. 1:27into any conclusion, just think about
  42. 1:29it. If interviewer will ask to me,
  43. 1:31possibly my answer would be, I would not
  44. 1:34immediately increase the database
  45. 1:35connection. First, I would find out why
  46. 1:37the existing connections are being held
  47. 1:39for so long. I would start with the
  48. 1:41connection pool matrixes. I wanted to
  49. 1:44know how many connections are active,
  50. 1:46how many are ideal, what are the maximum
  51. 1:48pool sizes and most importantly, whether
  52. 1:51the request are waiting for a connection
  53. 1:53or not. If all those things are looks
  54. 1:55normal, then we'll go to the next and I
  55. 1:57would look at the database monitoring
  56. 1:59and identify query is might be slowing.
  57. 2:01We will identify that any suspicious
  58. 2:03queries is there. I will use explain
  59. 2:05analyze in the post case SQL and
  60. 2:07actually doing the analysis of that
  61. 2:09query. Then I would check the long
  62. 2:11running transactions whether there will
  63. 2:13be any transaction which is long running
  64. 2:15and blocking the other to take a
  65. 2:18connection from a DB. Then I will
  66. 2:20investigate this will there hibernate
  67. 2:22having any N plus one query related
  68. 2:24issue or not because an API request can
  69. 2:27unexpectedly indicate hundreds of
  70. 2:29thousands of queries due to this N plus
  71. 2:32one query issue. And another important
  72. 2:34thing I would check in is whether the
  73. 2:36external API is happening while the
  74. 2:39database transaction is just open up. If
  75. 2:41an open transaction update the database
  76. 2:44call a third party API that makes a five
  77. 2:47second and only then commit a database
  78. 2:49connection may remains occupied for
  79. 2:51entire five second and it's enough
  80. 2:53request to this simultaneously the
  81. 2:55connection pool get exhausted. If the
  82. 2:57evidence is still not clear I would take
  83. 2:59a trade dump and identify whether the
  84. 3:02requests are actually blocked or not. So
  85. 3:05this way the senior level answer would
  86. 3:07be expecting. Don't increase the pool
  87. 3:09size and before understanding why the
  88. 3:11connections are being held because
  89. 3:13increasing the connection pool might
  90. 3:15temporarily hide the symptoms while
  91. 3:17making the database itself even more
  92. 3:19overloaded. And this is an important
  93. 3:21interview pattern. Whenever an
  94. 3:23interviewer give a performance problem
  95. 3:25don't jump directly to the configuration
  96. 3:27changes. First find out the resources
  97. 3:29that is being exhausted and then find
  98. 3:32why it is being exhausted. Now let's
  99. 3:34look at another problem where the
  100. 3:35performance is not the issue but the
  101. 3:37correctness is. Now in this question
  102. 3:40suppose a customer makes a payment and a
  103. 3:42client send the request to your API but
  104. 3:44because of the network timeout it didn't
  105. 3:46receive the responses. A client assumes
  106. 3:49the request failed and retries. Now the
  107. 3:51server receives the same payment request
  108. 3:53twice. Now the interviewer ask how would
  109. 3:56you prevent a duplicate payment? Now in
  110. 3:58this particular question there is a
  111. 4:00issue of requesting twice the same
  112. 4:02request. Now, first, the solution that
  113. 4:04comes into your mind is item potency.
  114. 4:06Now, I would ask the client to send the
  115. 4:09item potency key with the payment
  116. 4:11request. For example, item potency key
  117. 4:13is a b c or one two three like that.
  118. 4:15When the server receives the request, it
  119. 4:17stores that key along with the payment
  120. 4:19result. The database should also enforce
  121. 4:21a unique constraint on that key. Now,
  122. 4:23imagine the first request creates a
  123. 4:25payment successfully. When the retry
  124. 4:27arrives with the same key, the
  125. 4:29application detects that the this
  126. 4:31operation has been already processed and
  127. 4:33instead of creating another payment, it
  128. 4:35simply returns the original result. But
  129. 4:37there is an important architecture
  130. 4:39detail here. I would not rely only on
  131. 4:42the application level check because two
  132. 4:44identical requests can arrive at most
  133. 4:47exactly the same time. Both requests
  134. 4:49would check, does this key exist? Both
  135. 4:51might get no and both would then create
  136. 4:54a payment. And that's why the database
  137. 4:55uniqueness constraint is extremely
  138. 4:57important. It gives us a final
  139. 4:59consistency boundaries. And remember
  140. 5:01this principle, we tries are normal in
  141. 5:03distributed system. So whenever you
  142. 5:05design a payment or order or message or
  143. 5:08even event processing, always ask what
  144. 5:10happens if same request arrives twice.
  145. 5:13If your design has a good answer to that
  146. 5:15question, you are already thinking like
  147. 5:17a senior engineer. Now consider this
  148. 5:19scenario. You have a method annotation
  149. 5:21with at the rate transactional. Inside
  150. 5:23the method, you save an order, then you
  151. 5:26save a payment information, then an
  152. 5:28exception occurs. But surprisingly, the
  153. 5:30order is still committed. Now the
  154. 5:32interviewer asks, what could be the
  155. 5:34wrong? So in this such case, we need to
  156. 5:36check whether the transactions spring
  157. 5:38transaction proxy. We need in this the
  158. 5:41first thing we would investigate the
  159. 5:43first thing we would investigate is
  160. 5:45spring transaction proxy. At the rate
  161. 5:47transactional is normally implemented
  162. 5:50using a spring proxy. So we should ask
  163. 5:52is the method being called through
  164. 5:55another spring managed bean or is there
  165. 5:57a self invocation? Self invocation means
  166. 6:00like this dot create order. Now when a
  167. 6:02method inside the same object calls
  168. 6:05another transactional method directly.
  169. 6:07The spring proxy can be bypassed. I
  170. 6:10would also check the exception type. By
  171. 6:12default, string rollback transactions
  172. 6:14for unchecked exceptions such as runtime
  173. 6:16exceptions, but checked exceptions do
  174. 6:19not automatically triggered rollback in
  175. 6:21the same way. If the business
  176. 6:22requirement requires a rollback for a
  177. 6:25checked exception, we may need something
  178. 6:27like rollback for I would also verify
  179. 6:29that the correct transactional manager
  180. 6:32is being used especially in application
  181. 6:34involving multiple data sources. So we
  182. 6:37wouldn't simply say that add at the rate
  183. 6:39transactional. I would investigate
  184. 6:41whether the transaction actually exist
  185. 6:43around the operation or not. This is the
  186. 6:45exactly the difference between the
  187. 6:47mid-level and senior level answer. A
  188. 6:49mid-level engineer says that use at the
  189. 6:52rate transactional. A senior level
  190. 6:54engineer says that is a transaction
  191. 6:56actually being created and is the method
  192. 6:58being invoked through the spring proxy.
  193. 7:01Now I will explain about the spring
  194. 7:03proxy more. Now suppose we have a one
  195. 7:06class called order and another class
  196. 7:09called payment. Now the this particular
  197. 7:11class is having one method called create
  198. 7:13order and inside this create order at
  199. 7:16the transactional I am calling a payment
  200. 7:19class process payment method. Now if the
  201. 7:21process payment method is having at the
  202. 7:24rate transactional and it is defined in
  203. 7:26different bean, then there will be a if
  204. 7:28any exceptions will occur, then this
  205. 7:30particular transaction will be rolled
  206. 7:32back. The process payment transaction or
  207. 7:34receive transaction payment will be
  208. 7:35rolled back. But if this process payment
  209. 7:38process payment transaction method
  210. 7:40defined in the same bean like in order
  211. 7:42bean is sent, then the spring proxy will
  212. 7:45be bypassed and it will not roll back.
  213. 7:47Now this n plus one query problem. Here
  214. 7:49we are calling find all method which is
  215. 7:52loading thousand of orders. After this
  216. 7:54query, we have written that order dot
  217. 7:57get customer dot get name and that is
  218. 7:59also suddenly loading thousand plus
  219. 8:01queries again. Now the interviewer will
  220. 8:03ask that this is the n plus one query
  221. 8:05problem. Now how would you resolve this
  222. 8:07n plus query problem? Now, first we
  223. 8:09would confirm the problem using SQL
  224. 8:11logs, hibernate statistics, or APM
  225. 8:14traces. We don't want to optimize
  226. 8:16something that is not actually the
  227. 8:18bottleneck. So, once the confirmation
  228. 8:20will be done, there are several possible
  229. 8:22solutions for that. One of the solution
  230. 8:24is using @ entity graph. For example, we
  231. 8:27can explicitly tell JPA that the
  232. 8:29customer relationship is required for
  233. 8:32this particular use cases. Now, another
  234. 8:34option will be the fetch join. This
  235. 8:36allow us to retrieve the required
  236. 8:38related data as a part of the same
  237. 8:40query. Or we'd heavy APIs, we might
  238. 8:42prefer a DTO projections. Instead of
  239. 8:44loading complete entity graph, we
  240. 8:46retrieve only the fields that API
  241. 8:49actually needed. What I would avoid is
  242. 8:51blindly changing the relationship to
  243. 8:53eager. So, that can solve N+ query
  244. 8:55problem while creating another
  245. 8:57performance problem somewhere else
  246. 8:59because now every use of that entity may
  247. 9:02automatically load additional data. So,
  248. 9:04remember, don't ask should this
  249. 9:06relationship be eager? Ask what data
  250. 9:09does this specific use case actually
  251. 9:11need? This shift from entity-centric
  252. 9:14thinking to use case-centric thinking is
  253. 9:16very important at architect level. Now,
  254. 9:19we all know that in microservice
  255. 9:21architecture, there are number of
  256. 9:23instances are running for a particular
  257. 9:25microservice. So, suppose we have five
  258. 9:28different Spring Boot instances running
  259. 9:31into a production and out of these five
  260. 9:33different instances, four are healthy
  261. 9:36and one instance is repeatedly crashing
  262. 9:38with out of memory error. Now, in this
  263. 9:40particular scenario, interviewer might
  264. 9:42be asked how would you investigate why
  265. 9:44this is happening? Now, the first
  266. 9:46question would be why is only one
  267. 9:49instance affected? So, we would compare
  268. 9:51the traffic and memory consumption
  269. 9:54across all five instances. Maybe one
  270. 9:56instance is receiving significantly more
  271. 9:59traffic or maybe an load balancer is not
  272. 10:01distributing traffic evenly or perhaps
  273. 10:04that instance is processing a specific
  274. 10:06type of request. Then we would
  275. 10:08investigate the heap usage, old
  276. 10:10generation growth, garbage collection
  277. 10:12behavior, threads count, thread local
  278. 10:14usage, static references, cache growth,
  279. 10:17and an unusually large collections. We
  280. 10:20would also capture a heap dump from
  281. 10:22affected instances if possible. And the
  282. 10:25heap dump can help to identify which
  283. 10:28objects are consuming memory and whether
  284. 10:30some objects are unexpectedly being
  285. 10:33retained. We would also compare the
  286. 10:35cache size between healthy and unhealthy
  287. 10:38instances. The key is to determine
  288. 10:40whether it is a memory leak, an even
  289. 10:43profit, or a cache growth problem, or an
  290. 10:45instance spreading workload. We would
  291. 10:47not immediately increase the heap size
  292. 10:49because that would simply delay the
  293. 10:51crashes. Now here is the architect
  294. 10:53mindset. When only one instance fails,
  295. 10:56don't immediately blame the entire
  296. 10:58application. Compare the healthy
  297. 11:00instances with the unhealthy one, and
  298. 11:02the difference between them often
  299. 11:04contain the answer of this question. Now
  300. 11:06imagine two users read the same account
  301. 11:09balance, both see the same value, both
  302. 11:11make changes, and one user update
  303. 11:14overrides the other update. Now
  304. 11:15interviewer will ask, how would you
  305. 11:17prevent the last updates? Common
  306. 11:19solution is optimistic locking. In JPA,
  307. 11:22we can add a version field using @
  308. 11:24version. For example, we have a private
  309. 11:27long version field and hibernate that
  310. 11:29includes the version in the update
  311. 11:30condition. So effectively the update
  312. 11:33says update this row only if the version
  313. 11:36is still the same version I originally
  314. 11:38read. If another transaction has already
  315. 11:40modified the record, the version will be
  316. 11:42changed and the update fails. Now at
  317. 11:45this point, the application can retry
  318. 11:47the operation or return a conflict to
  319. 11:49the user. This work very well when
  320. 11:52contention is relatively low. If there
  321. 11:54is a extremely high contention and we
  322. 11:57genuinely need a row level
  323. 11:59serialization, pessimistic locking may
  324. 12:01be a more appropriate. But I wouldn't
  325. 12:03automatically choose pessimistic locking
  326. 12:05because it can reduce the concurrency
  327. 12:08and introduce lock contention. So the
  328. 12:10interviewer answer is not simply use at
  329. 12:13the rate version. The better answer is
  330. 12:16use optimistic locking when contention
  331. 12:18is reasonable and choose pessimistic
  332. 12:21locking when the business actually
  333. 12:23requires strong serialization. Now in
  334. 12:25this scenario, your spring boot API
  335. 12:27works perfectly on your system, but
  336. 12:30after deployment to the production,
  337. 12:32requests start timing out. Now in this
  338. 12:34case, interviewer will ask what is your
  339. 12:36approach to check this issue? So we
  340. 12:39would trace the entire request path
  341. 12:41first and then the client, load
  342. 12:43balancer, network and security layer,
  343. 12:46application instances, database and
  344. 12:48external APIs. I would verify
  345. 12:51environment variable and active spring
  346. 12:52profiles, then credentials and secrets,
  347. 12:55then possibly whether the production
  348. 12:57endpoint is correct or not, then the DNS
  349. 12:59resolution, maybe the TLS configuration,
  350. 13:02port, security group, firewall, network
  351. 13:04routing, everything. The application
  352. 13:06might be trying to connect to a database
  353. 13:08endpoint or which can be locally
  354. 13:11accessible but blocked in the production
  355. 13:13subnet. So we we need to check all the
  356. 13:15possibilities here. In apart from this
  357. 13:18mentioning that only a code related
  358. 13:20issue. So a production profile might
  359. 13:22pointing to a different external
  360. 13:24services as well. So these things also
  361. 13:26we need to be checked. So would avoid
  362. 13:28assuming that spring boot itself is a
  363. 13:30problem. In this particular scenario
  364. 13:33based question, we need to define a
  365. 13:35generic methodology where all the
  366. 13:38possible things we need to be checked
  367. 13:40before we say that this is the problem
  368. 13:42related to a spring boot itself. So
  369. 13:44production only problem is often a
  370. 13:46system problem, not a code problem. That
  371. 13:48would be the basic idea you would have.
  372. 13:51Now don't just inspect the Java
  373. 13:52application blindly. Trace the entire
  374. 13:55path first from the client to the
  375. 13:56dependency and that would be your
  376. 13:58generic answer in this particular
  377. 14:00scenario because nobody can provide a
  378. 14:02perfect answer in this particular
  379. 14:03scenario based question. So the problem
  380. 14:05might be at particular level, but we
  381. 14:08need to be lean to that particular
  382. 14:10problem. So to get that particular
  383. 14:13issue, we have to check all possible
  384. 14:16scenarios in this case. Now this
  385. 14:17question in the scenario where your
  386. 14:20third party API is getting slow. So
  387. 14:22suppose you have API calls a payment
  388. 14:24service. Sometimes the provider taken 10
  389. 14:27seconds to respond. Your own API becomes
  390. 14:30slow because of it. Now interviewer will
  391. 14:32ask how would you make your API
  392. 14:33resilient? So for synchronous
  393. 14:35communication, I would start the strip
  394. 14:37connection and read timeouts then the
  395. 14:39bounded retries, not unlimited retries.
  396. 14:42Retries should generally use exponential
  397. 14:45backoff. So I would also consider a
  398. 14:47circuit breaker if the payment provider
  399. 14:49is consistently failing or timeout. The
  400. 14:52circuit breaker can prevent every
  401. 14:54application request from waiting for a
  402. 14:57some failure dependencies. So bulkhead
  403. 14:59isolation is another important pattern.
  404. 15:02The goal is to prevent one slow
  405. 15:04dependency from consuming all
  406. 15:06application resources. If the business
  407. 15:08allows a synchronous processing, I would
  408. 15:10consider a completely different
  409. 15:11architecture. The API is calling or
  410. 15:14pushing the messages into Q and Kafka
  411. 15:16broker then the payments provider. Now
  412. 15:18the client doesn't have to keep an HTTP
  413. 15:21connection open while waiting for an
  414. 15:23external provider. Now this is a classic
  415. 15:25distributed system principle. Never
  416. 15:27allow an external dependency to consume
  417. 15:30unlimited resources inside your
  418. 15:32application. Timeouts, retries, circuit
  419. 15:34breakers, bulkheads, asynchronous
  420. 15:36processing are the tools to protect your
  421. 15:38system from someone else's failure. Now
  422. 15:41this question is related to @ async.
  423. 15:43Suppose you have added @ async to a sent
  424. 15:46email method, but when you send a test
  425. 15:48it, the method is still running
  426. 15:50synchronously. Now the interviewer will
  427. 15:52ask that what could be the possible root
  428. 15:54cause for this? Now first they would
  429. 15:56check whether the asynchronous
  430. 15:57processing is enabled with @ enable
  431. 16:00async or not. Then we would check
  432. 16:02whether the method is being invoked
  433. 16:04through the spring proxy or not. Like
  434. 16:06suppose you have been called send email
  435. 16:08method using this this dot send email
  436. 16:11method and this actually bypassing the
  437. 16:13proxy. Instead this asynchronous method
  438. 16:16should normally be invoked through
  439. 16:17another spring managed bean. You would
  440. 16:20also look at the executor
  441. 16:21configurations. In production, we
  442. 16:23wouldn't rely blindly on an unbounded
  443. 16:25default configuration. We would
  444. 16:27configure a bounded thread pool task
  445. 16:30executor with appropriate core threads,
  446. 16:32maximum threads, and queue capacity
  447. 16:34because the asynchronous does not mean
  448. 16:36unlimited and that's simply move the
  449. 16:38bottleneck somewhere else unless you
  450. 16:40control the executor. So whenever you
  451. 16:43hear at the rate async immediately think
  452. 16:46that proxy plus executor plus capacity.
  453. 16:48Now in this question, suppose the
  454. 16:50configuration data changes only once per
  455. 16:53day but and your API received 50,000
  456. 16:56request every hour that repeatedly read
  457. 16:58that configuration. Now interviewer will
  458. 17:00ask what would be your approach in this
  459. 17:03particular case? So this is a good cache
  460. 17:05candidate. So this is a good caching
  461. 17:08candidate. Now we would cache the
  462. 17:10expensive reads, for example, using
  463. 17:12string cache at the rate cacheable and a
  464. 17:15configuration key would be passed over
  465. 17:16here. Now for a single application
  466. 17:18instance, caffeine can be a very good
  467. 17:20local cache option but if we have a
  468. 17:22multiple application instances and all
  469. 17:25instances need a shared view of the
  470. 17:27cache, we might consider a radish or
  471. 17:29another distributed cache like ignite as
  472. 17:32well. So however, we wouldn't choose a
  473. 17:34cache simply because it's fast. We would
  474. 17:36evaluate how frequently date does the
  475. 17:39data changes, how stale can the data be,
  476. 17:42how validation will be happening, how
  477. 17:45much memory will the cache consume, and
  478. 17:48what happen if the cache is unavailable,
  479. 17:50and how many application instances need
  480. 17:53to be that particular data. So the
  481. 17:55senior level caching question is not
  482. 17:57like should I use radish? It is like
  483. 18:00what the consistency, latency,
  484. 18:02invalidation, scalability requirement
  485. 18:04does this data have? Now this question
  486. 18:06is dedicated to the Kafka. Spring Boot
  487. 18:09Kafka consumer occasionally receive the
  488. 18:11same event twice. Now the interviewer
  489. 18:13will ask him how do you make sure the
  490. 18:16processing will be safe? Now we would
  491. 18:18make the a operation idempotent. Every
  492. 18:21event should have a unique event ID.
  493. 18:23Before processing the event, the
  494. 18:25consumer check whether that the event ID
  495. 18:27has been already been processed or not.
  496. 18:29If it has, the consumer can safely
  497. 18:32ignore the duplicate. If it hasn't, then
  498. 18:34the process the event with the event ID.
  499. 18:36We would enforce uniqueness at the
  500. 18:38database level as well. The important
  501. 18:40point is that you would not rely purely
  502. 18:43on messaging system to guarantee exactly
  503. 18:46once the business behavior will occur
  504. 18:48because even if message delivery
  505. 18:50semantics are strong, the business
  506. 18:52operations may involve external systems
  507. 18:55or database operations as well. So the
  508. 18:57business operation itself should be
  509. 18:58designed to tolerate duplicate delivery.
  510. 19:01Whenever we are designing the Kafka
  511. 19:03consumers, remember at least once
  512. 19:06delivery means duplicates are a normal
  513. 19:09possibility. Do design your consumer
  514. 19:12assuming that Kafka will never send this
  515. 19:14message twice. But design it so that the
  516. 19:16processing it twice is harmless. Time
  517. 19:19scenario, suppose an API returns a huge
  518. 19:22list around 1 lakh records. The memory
  519. 19:25usage is high. Response time is slow.
  520. 19:27Now the interviewer is asking, what
  521. 19:29would you make a change in this case?
  522. 19:31First, I would avoid returning all
  523. 19:34records in a single request. We would
  524. 19:36introduce a pagination for moderate data
  525. 19:39set, traditional limits and offset
  526. 19:41pagination can work. But for very large
  527. 19:43data set, key set pagination is often
  528. 19:45better. For example, you have written a
  529. 19:48query where you have mentioned where ID
  530. 19:50is greater than last ID followed by
  531. 19:53order by ID and limit this particular
  532. 19:56size. Now instead of asking the database
  533. 19:58to skip the hundred of thousands of
  534. 20:00rows, we will continue from a known
  535. 20:03position. I would also return only the
  536. 20:06field required by an API rather than
  537. 20:09loading complete entity. So when someone
  538. 20:12say the API is slow because there is a
  539. 20:15too much data, don't just increase the
  540. 20:17memory. Ask why are we transferring and
  541. 20:19processing the data that the client does
  542. 20:22not need. So have to shrink the data in
  543. 20:25the API which only are required for a
  544. 20:28particular API response. That way we can
  545. 20:32make this API faster. Also the
  546. 20:34pagination would be the best approach in
  547. 20:37case of processing data with a huge
  548. 20:39load.
  549. 20:40Now here this particular scenario is
  550. 20:42based on a CPU spike. Now suppose we
  551. 20:45have a database CPU is normal but one
  552. 20:48spring boot instance suddenly reaches
  553. 20:4995% CPU. Now the interviewer is asking
  554. 20:52how would you troubleshoot this problem?
  555. 20:55Now we would start with the evidence.
  556. 20:57First the CPU and the thread matrix.
  557. 20:59Then we would capture a thread dump as
  558. 21:01well and we want to identify which
  559. 21:04threads are consuming the CPU and what
  560. 21:07they are doing. By that way we are going
  561. 21:10to lean to the problem so that we can
  562. 21:12find identify the root cause and solve
  563. 21:15the issue. Now we would investigate the
  564. 21:17infinite loop, expensive sorting,
  565. 21:19serialization, regular expression, busy
  566. 21:22polling and garbage collections as well.
  567. 21:24If required we would use profiling to
  568. 21:27identify the hot code path as well. For
  569. 21:30example, maybe a piece of business logic
  570. 21:32is accidentally performing an expensive
  571. 21:34operation thousands of times. So we
  572. 21:36would not start changing JVM flag before
  573. 21:39identifying the actual code path. Now
  574. 21:41the high CPU is a symptom. The important
  575. 21:44question is not how do I reduce the CPU
  576. 21:47utilization? The important question is
  577. 21:49which code is consuming the CPU and why?
  578. 21:52And that brings us the end of part one.
  579. 21:54We have covered 15 real world Java
  580. 21:56Spring Boot, JPA, Hibernate and
  581. 21:58Postgress interview scenario but we have
  582. 22:00only done halfway through. As part of
  583. 22:03second we will tackle next 15 questions
  584. 22:06and
  585. 22:06they are even more interesting and
  586. 22:08challenging. If you found this useful,
  587. 22:10please subscribe the channel and comment
  588. 22:12below which scenarios you have found
  589. 22:14most interesting. Thank you for
  590. 22:16watching. I will see you in next part.
  591. 22:18uid:0

About this transcript

This page contains the full transcript of 30 Java & Spring Boot Scenario-Based Interview Questions | Real-World Production Problems | Part 1 by TechFestJava, generated from the public captions YouTube serves with the video. The transcript has 3,698 words across 591 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.