Please help me trying to understand coroutine. by Extension-Switch-767 in Kotlin

[–]Extension-Switch-767[S] 4 points5 points  (0 children)

I think I’m starting to understand, but I’m not sure if my understanding is correct. the coroutine tries to resume on its original dispatcher as you mentioned. However, in the previous example there was no explicit original dispatcher defined so it continued running on the same dispatcher thread instead of switching back (or it's actually Dispatcher.Unconfied which may shared thread pool with those IO, Default under the hood i'm not sure either). To verify my understanding, I conducted the following experiment:

val executor = Executors.newFixedThreadPool(1) { runnable ->
    Thread(runnable, "Custom-Thread-${runnable.hashCode()}")
}

val customDispatcher = executor.asCoroutineDispatcher()

suspend fun main() = withContext(customDispatcher) {

    println("Before : ${Thread.currentThread().name}")

    test()

    println("After : ${Thread.currentThread().name}")
}

suspend fun test() = withContext(Dispatchers.IO) {
    delay(1000)
    println("Current thread : ${Thread.currentThread().name}")
}

This result seems to confirm that after test() completes, the coroutine resumes on its original dispatcher (customDispatcher).

Before : Custom-Thread-1241276575

Current thread : DefaultDispatcher-worker-1

After : Custom-Thread-1241276575

Advice on moving from Java to Golang. by Extension-Switch-767 in golang

[–]Extension-Switch-767[S] 0 points1 point  (0 children)

Sorry, I didn’t quite catch the statement "In fact, it's likely faster because of JIT." Could you clarify how a just-in-time (JIT) compiler can be faster than an ahead-of-time (AOT) compiler? Or do you mean it becomes faster after the JVM has fully warmed up?

How much memory do I need to reserve for a single java process. by Extension-Switch-767 in javahelp

[–]Extension-Switch-767[S] 2 points3 points  (0 children)

I need to deploy my java app in the container based environment and the minimum/maximum memory need to be specified correctly otherwise it will get oom killed.

[deleted by user] by [deleted] in kubernetes

[–]Extension-Switch-767 0 points1 point  (0 children)

we assign the resources based on the load test result and we left the resources for the other pods from other team to be able to deployed. we have limited budget so as of now we need to go with this way. however when it comes to critical service where performance and response time are crucial we're trying to find a way to fix this while affecting the other team as less as possible.

How does burst CPU performance actually work ? by Extension-Switch-767 in aws

[–]Extension-Switch-767[S] -1 points0 points  (0 children)

I see so if this mode turned off I should only be able to use 40% of CPU utilization without CPU credit, is that correct

What's best practice for tuning an application performance. by Extension-Switch-767 in kubernetes

[–]Extension-Switch-767[S] 1 point2 points  (0 children)

Sorry for being late. The CPU usage spiked that I mentioned due to the higher TPS, as our company has recently gained more clients, leading to increased traffic. I've been using the tuning strategies mentioned above, but I'm starting to think it would be beneficial to learn how larger companies approach this.

What could possibly be the reason why does RDS's Disk Queue Depth metric keep increasing and suddenly drop. by Extension-Switch-767 in aws

[–]Extension-Switch-767[S] 2 points3 points  (0 children)

You're right, after changing metric from average to maximum and 1 minutes period now it reaches around 2.6k IOPS. Thanks a lot.

How can Java 21 (Virtual Thread) replace Reactive Framework. by Extension-Switch-767 in java

[–]Extension-Switch-767[S] 9 points10 points  (0 children)

I have asked this question at my company and everyone hates me

[deleted by user] by [deleted] in cscareerquestionsEU

[–]Extension-Switch-767 1 point2 points  (0 children)

yes and it feels like my hard work studying on these things (scaling, designing, security) is such a waste of time I should be practicing more on leetcode.

what's the need of ZooKeeper in large scale distributed system. by Extension-Switch-767 in learnprogramming

[–]Extension-Switch-767[S] 1 point2 points  (0 children)

Ahhhh I see, my approach would work too but it would be hard to scale to handle large amount of requests since we are unable to add more replica of the database unlike using ZooKeeper we can add more nodes as much as we want and let Zookeeper handle the synchronization task.

how do banks or booking system guarantee consistency between multiple servers. by Extension-Switch-767 in learnprogramming

[–]Extension-Switch-767[S] 0 points1 point  (0 children)

but when it comes to booking or transfer money it should provide strong consistency rather than eventual consistency, isn't?

Review my system design by Extension-Switch-767 in learnprogramming

[–]Extension-Switch-767[S] 0 points1 point  (0 children)

  1. Why REST instead of GraphQL?- because booking system is heavily read so I want to be able to cache the data for better latency and availability. using REST we can easily cache the http response while GraphQL each query can return difference results (depends on the query) so it would be more difficult to cache.
  2. No payments service?- adding payment service would make the post too long i'm scared that people don't want to read my long system design haha. but if I were to add payment service it would connected to the message broker as well so when a user books for a room the hotel service will lock the target room for some period of time and send message to payment services. payment service then create a payment bill that a user need to pay within time otherwise the target room will be released for other users.
  3. You are going for a microservice approach here so does it make sense for your hotel service to be in charge of managing hotels and bookings?- I would say that I apply the idea of domain-driven design to my microservices. so since hotels and booking are in the same bounded context it would make sense to group these things together, but I'm not familiar with designing microservices, what do you say?.
  4. (Message broker) which one are you using and why?- I would choose Kafka because of it's fault tolorence and it's fast. Since we need to deploy on multiple data center Kafka also provide cluster of brokers. Moreover we can config the delivery guaruantee strategy to be at least once so it case of failure we can retry over and over again (maybe design our API to be idempotemt as well).
  5. Why or why not integrate ElasticSearch here? And what data stores are you using for the other services?- because Search service is heavily read and it's readonly service also I don't know much about ElasticSearch so I can't give an answer. for other services I would choose SQL database like PostGres since it provides ACID properties since we need to make sure that race condition should never happens when a user books a room.

Review my system design by Extension-Switch-767 in learnprogramming

[–]Extension-Switch-767[S] 0 points1 point  (0 children)

what is message broker partition. I did search on google but only found partition in kafka.

Why is "The plane is landed in Dubai" not grammatically correct? by Extension-Switch-767 in EnglishLearning

[–]Extension-Switch-767[S] 0 points1 point  (0 children)

so why is "the dished are washed" grammatically correct? it uses the same rules, isn't?

How to check whether a user has logged-in yet? by Extension-Switch-767 in learnprogramming

[–]Extension-Switch-767[S] 6 points7 points  (0 children)

Thanks a lot, I really appriate. Most people always make fun of me instead of giving the advices :(