發表文章

journal 20260206

markdown It's me again! BTC, ETH and the market is fallen down!!! OMG XD But I have about 43% free money and ready to buy it! so come on! Today I still stick on my plank plan.

journal 20260205

markdown Okkkkkkkkk! Today is a tiring day! I'm so tired cuz I was in meetings all day!! Today is Spring Grooming day and we plan to use an unimplemented API with our system!!! so we have to consider these sense like bypass, undesign schema, etc. And imagine how to integrate with that system. but at least there is one thing I am happy that tomorrow is holiday! I am taking my annual leave cuz if I don't use it, it will expire, that is law in my country. BTW, I still sticking my plank plan.

journal 20260204

markdown Hey guys, today I want to writing something. I go to my company and work with my college together, after work we eat susi, the steam egg is so amazing in this place. we discuss about vc/vp did and api flow among new server and old application server, and try to figure out how to make UI/UX useable with pm. Today I hold plank in `01:25`, BTW my arm had some pain so to take some soft pillow?(cart?) ont the ground, I feel better. anyway, today is tired day. so I goona sleep early today. bye guys.

journal 20260203

markdown Today is my Plank workout day 3, I can hold in `02:01` second, I will continue do it. I starting to make probiotics live in my body, so I take `NOW Foods` 's Probiotic-9 50Billion. I hope I can overcome the milk digestion issue. I refactor my company code with follow: ```ts // old export const LinkTypes = ['facebook', 'youtube', 'instagram', 'linkedin', 'x'] as const; export type LinkType = typeof LinkTypes[number]; ``` ```ts // new export const LinkType = {   Facebook: 'facebook',   Youtube: 'youtube',   Instagram: 'instagram',   Linkedin: 'linkedin',   X: 'x', } as const; export type LinkType = typeof LinkType[keyof typeof LinkType]; export const LinkTypes = Object.values(LinkType) as readonly LinkType[]; ``` It can compatible with old usage like `const link: LinkType = 'facebook'`. Also can use readable and no typing string like `const link: LinkType = ...

The first day of journal

markdown Today I make an decision that I will write something every day. cuz I want to imporve my English output skills. I want writting journal to be a habbit. I make some rule to let this things easy to execute. Here is my rules. ```markdown Try to use English to write something. - Consistantly to do this. - Don't correct any syntax or gramma or words until I used to write this journal. - Don't care how the essay length I should write, just consistant write. - Upload to the blog. Whatever. ``` This rule may change after I write every day and I wil not feel terrible to write. I don't know whether I can continue to do it, but at least this is a good start. Today I go jogging with my friends, tired but we achive our goal. Ibit is fall down to 44.40, Oh my god that is horrible.

關於RCA

圖片
markdown # 關於RCA * RCA : 根本原因分析 ## 結論 * RCA是一種通用報告的格式,提供了一些通用的方法與計巧,讓問題可以從根本上被解決,可以參考[Here](https://asq.org/quality-resources/root-cause-analysis#resources) ## 我們小組上使用的簡易格式 * I. Problem Statement -> 定義/描述問題 * II. Cause & Effect -> 分析原因/造成影響 * III. Solution & Evaluation -> 提出解決方案/評估可行性 * IV. Topics behind the scenario -> 延伸討論 (如果還有的話) ### 節錄部份壓測的RCA報告 ```markdown ## I. Problem Statement * 接入平台需要能承受較大量的用戶。 * 壓測試後發現承載人數低下。 * 測試行為,登入 + 打訊息 + 圖片上傳 & 只打訊息,以不同的人數成增長與訊息數量測試。 ## II. Cause & Effect ### 登入導至OOM * 登入API 密碼加密每次使用64MB空間加密 -> 過多記憶體導至系統崩潰。 ### 併發下物件過多導至GC壓力 * 部份API在高併發下產生大量的物件建立與釋放 -> 使CPU 70%以上的時間花費在GC回收上 ### 編解碼使用的方式不適合高併發場景 * 通訊server的編解碼使用`map[string]interface` -> CPU效能 + GC壓力 ... ... ## III. Solution & Evaluation ### 登入導至OOM * 將密碼加密使用的空間降低 * 需注意玩家的token失效問題 * 要編寫過渡的程式才能無感更換 ### 併發下物件過多導至GC壓力 * 對於重覆使用的物件,在高併發下應使用sync.Pool池來減少GC壓力 ### 編解碼使用的方式不適合高併發場景 * 通訊server的CPU壓力可以透過多台機器分擔壓力(目前的做法) * 或調整編解碼方式減少物件壓力 * 由於MQ訊息沒分離,解決...

Slice沒照預期的切片

圖片
markdown ## 結論 在使用make初始化slice的時候,要考慮初始的長度,若是只用兩個參數會使長度等於容量,也就是已經初始化過了,這時再用append的話就不會如想像那樣從頭開始新增資料了! ## 環境 go v1.19.6 ```go type Card struct { Word string Explain string } ``` ## 預期的對照組 * 這是正常運行的 ```go stackB := []Card{ { Word: "test", Explain: "test", }, { Word: "test2", Explain: "test2", }, { Word: "test3", Explain: "test3", }, } fmt.Println(stackB) // worked stackB = stackB[:2] fmt.Println(stackB) // worked ``` ## 非預期的狀況 ```go stack, _ := GetCardMap() fmt.Println(stack) // worked stack = stack[:2] fmt.Println(stack) // only 2 empty element func GetCardMap() (m []Card, err error) { file, err := os.Open("frequecydic.txt") if err != nil { return nil, err } defer file.Close() totalCount, err := VerifyDic(file) if err != nil { return nil, err } // move file pointer to the beginning of file _, err = file.Seek(0, io.SeekStart) if err != nil { return nil, err...