見出し画像

8/28 I/O日記

inorderIdx = {}
        for i, v in enumerate(inorder):
            inorderIdx[v] = i
inorderIdx = {v: i for i, v in enumerate(inorder)}

One-liner code like the above can sometimes be easier to read and more concise. I find it beneficial to use them occasionally.


AWS SQS and EC2 Auto-Scaling

When using SQS with EC2 Auto-Scaling as a consumer, the auto-scaling function works based on a simple algorithm like [number of messages / number of EC2 instances]. The resulting value determines whether additional EC2 instances should be launched.


Efficient Messaging Service

If you want to send messages to multiple consumers, using SNS & SQS (fanout type) is a good approach. SNS has a Pub/Sub function where a publisher can send a message to all subscribers simultaneously. This method is called the fan-out type. On the other hand, if you are sending a message to a single consumer, use SQS (Simple Queue Service).


Kinesis Data Streams vs. Kinesis Firehose

Kinesis is a data stream service in AWS.

  • Kinesis Data Streams: Allows you to customize data in real time and immediately send it to other services.

  • Kinesis Firehose: Ideal for efficiently sending data to other AWS resources that will use the data.


OS: Concurrent Programming

Concurrent programming is essential even for computers with only one CPU. For example, in a web browser, when browsing a webpage, a computer uses multiple threads. One thread is for fetching data and writing it to the register, and another is for rendering data to your display. Without concurrent programming, we wouldn't be able to use computers as comfortably as we do today.


Deadlock and Livelock

  • Deadlock: A situation where two or more processes are waiting for each other, and none can proceed.

  • Livelock: Similar to deadlock, it also stops processes, but the processes are still running internally without making progress.

いいなと思ったら応援しよう!