Swift

max, min Int.max Int.min Float.infinity –Float.infinity Double.infinity –Double.infinity label vs no label vs “_” Below are the ways passing variables func myFunc(label name: Int, lable name2: Int, age: Int, _ value: String) {     print(name)     print(name2)     print(age)     print(value) } myFunc(label: 4, lable: 3, age: 5, “aa”) default, no… Read More »

spinnaker

manifest, in kubernetes, it is used to create/modify resources, such as pod. Normally it is .yaml file. For example kubectl apply -f my-file.yaml artifact, a deployable resource. Could be docker image, git repo, github file, http file, s3 object etc chart, a combined K8S yaml manifests helm, is a tool. Similar to yum, apt in

Category: web

aws profile

➜ GettingStarted git:(master) ✗ aws configure –profile “sandbox” AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: us-west-2 Default output format [None]: ➜ GettingStarted git:(master) ✗ aws s3 ls s3://xxxx-bucket –profile sandbox

Category: aws

How Kinesis getShardIterator works

getShardIterator, by its name, it gets the iterator for the shard. get-shard-iterator –stream-name <value> –shard-id <value> –shard-iterator-type <value> [–starting-sequence-number <value>] Let’s say we use getShardIterator, we got iterator on shard2, seq2_0. Then we use this iterator to iterate message in Kinesis shard2 from seq0_0. After one iteration, it returns next iterator which points to seq2_1. If we want… Read More »

Category: aws

Thought about leaderboard

First of all, we can have below schema for the players and its score: contest_id(partitionKey), user_id1(sortKey), problem1_finish_time, problem2_finish_time, score(secondaryIndex) For the score and user_id, we can build a BST. Let’s say we want to find the players who ranks between 50-60. We can find the 50th player in O(logN) time. Check this leetcode problem. Then, we… Read More »

How to calculate percentile metrics

Suppose we want to calculate latency in p90 percentile. Use count min sketch to count each latency times. For example, 5ms happened 10 times, 9ms happened 20 times etc Because latency has long tail. That means most of latency is around 7ms, but there could be cases for 100ms, 110ms etc. For that long tail latency,… Read More »

Aws cli, put/get kinesis record

AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx AWS_SESSION_TOKEN=xxxx \ aws kinesis put-record \ –region us-east-1 \ –stream-name ${streamName} \ –data “{\”pengliid\”: \”pengli\”,\”value\”: [\”1\”, \”2\”, \”3\”, \”4\”]}” \ –partition-key pengli-id In the output, remember the sequence number and shardId AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx AWS_SESSION_TOKEN=xxxx \ aws kinesis get-shard-iterator \ –region us-east-1 \ –stream-name ${streamName} \ –shard-id ${shard_id} \ –shard-iterator-type AT_SEQUENCE_NUMBER \ –starting-sequence-number ${sequence_number}… Read More »

Category: aws

Cache TTL consideration

When there is no eviction mechanism, we can use ttl to invalidate. But this is based on that cache might have stale data. TTL doesn’t lead 100% cache correctness. If we want to guarantee cache correctness, we need evection mechanism, write-through etc strategies. In theory, TTL is just a way of data replacement. Others are LRU, LFU.