<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by R. H. on Medium]]></title>
        <description><![CDATA[Stories by R. H. on Medium]]></description>
        <link>https://medium.com/@rh-tw?source=rss-3abc261afc12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3J5sKrLSTL7J9hg57zBRiw.jpeg</url>
            <title>Stories by R. H. on Medium</title>
            <link>https://medium.com/@rh-tw?source=rss-3abc261afc12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:23:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rh-tw/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[學渣海外工作的那一年 — 加拿大/新加坡]]></title>
            <link>https://rh-tw.medium.com/%E5%AD%B8%E6%B8%A3%E6%B5%B7%E5%A4%96%E5%B7%A5%E4%BD%9C%E7%9A%84%E9%82%A3%E4%B8%80%E5%B9%B4-%E5%8A%A0%E6%8B%BF%E5%A4%A7-%E6%96%B0%E5%8A%A0%E5%9D%A1-1c920c4d1170?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c920c4d1170</guid>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 17:24:15 GMT</pubDate>
            <atom:updated>2024-01-10T17:24:46.275Z</atom:updated>
            <content:encoded><![CDATA[<h3>學渣海外工作的那一年 — 加拿大/新加坡</h3><p><strong>TL;DR </strong><br>簡單說說背景, 身為一個在學校從不認真, 大學科科重修的學渣, 投一堆履歷也沒人要鳥我. 差點以為搞不好只能去喊歡迎光臨 ?!<br>再到混了個碩士文憑 終於騙到一些大公司 offer <br>(不得不說在台灣 即便是走相較科技業沒那摸看學歷的純軟產業 有個 Master 對職場菜鳥還是有差的 體感上面試機會增加了不少 ?!)<br>來到海外前在台灣工作大概 3 年多, 分別在系統廠跟新手村.</p><h4><strong>[為何到海外工作]</strong></h4><p>台灣說實在不是純軟的市場, 叫的上號的 Tier 1 沒幾間, 也不想去啥竹科.<br>身為個純軟碼農當然心中總有個矽谷夢 想體驗看看世界級的公司怎摸運作的. 但現實總是骨感, 沒個當地學歷人脈 全部只能自己摸索的條件下, 要搞個 H1B 還是相對困難. <br>而撇除美國市場, 對於碼農而言 UK / Ireland / Japan / Singapore <br>算是全球市場待遇次加的地方 坡坡又算是轉換成本較低 稅制也低的地方</p><p>很多人在網路上的那些成功經驗分享, 背景 / 學歷 / 運氣 / 實力 都佔了很大一部分, 某種程度上是存在幸存者偏差的。我想我應該從來都不能算是運氣好的那群人, 雖然表面上去過兩個國家工作看似順遂, 但也是走走跌跌, 抓住了機會, 也花了非常多時間補足碼農知識才走到今天, 終於在海外工作一年有餘.</p><p>至於怎摸有機會去加拿大 / 新加坡 又都是另一段故事了, 基本上要感謝中美關係緊張 ?! 不少企業出海設立據點 多了不少海外的工作機會哈</p><p>接下來簡單用一個直男碼農的第一視角, 記錄下這一年兩國的體感差異</p><h4><strong>[工作與生活]</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*yLhtpivMWCXIfcjG.jpg" /><figcaption><a href="https://www.kanatanetworker.com/kanata-north-gears-up-for-discover-technata-career-fair/">https://www.kanatanetworker.com/kanata-north-gears-up-for-discover-technata-career-fair/</a></figcaption></figure><p>加 :</p><p>所在座標是渥太華, 一些對於渥太華的相關介紹, 除了是加拿大行政首都外, 還可以看到號稱 “北方矽谷” 的一些章節. <br>不過實際到了當地並沒有想像中繁榮, 滿滿科技公司林立的園區, 反而是林林散散的當地企業居多. 可以看出政府曾經規劃要把這區打造成加拿大矽谷, 不過發展不如預期的感覺.</p><p>不負責任的推測是渥太華位置尷尬, 人口又少, 左有 Toronto, 右有 Montreal, 下面還有個 New York. 可能就業人口都往那擠了吧！</p><p>不過在北美時候的生活, 大概是早上 9–10 上班, 下午 5 點前閃人 (其實這還算晚的, 當地人下午 3-4 點 下班的更多) <br>下班後有人去遛遛小孩, 賣場買菜回家做飯, 運動場 / 森林 運動, 工作跟生活在亞洲人看來真的是不可思議的完美平衡, 輕鬆又愜意, 真的可以理解為啥會有許多人花費心力也要舉家或是把小孩送來這成長. 生活的天堂呀！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHQj5t01v_-7AIlD_F8Gpw.png" /><figcaption><a href="https://ontariobiketrails.com/item/south-march-mtb-trail/">https://ontariobiketrails.com/item/south-march-mtb-trail/</a></figcaption></figure><p>(渥太華隨處都是這種平坦森林, 公司和這家附近都可以找到, 下班後可以森林裡散步 / 跑步 / 騎 mountain bike)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*vvuHYOm2R1wl53cm" /><figcaption><a href="https://www.straitstimes.com/singapore/consumer/average-hotel-room-rates-here-hit-14-year-high-in-september-2022">https://www.straitstimes.com/singapore/consumer/average-hotel-room-rates-here-hit-14-year-high-in-september-2022</a></figcaption></figure><p>坡 :</p><p>這邊就業市場應該不用多說, 應該是亞洲區首屈一指的, 三分之一的世界 500 強企業的亞洲總部都在這. 基本上各公司據點都圍繞金沙酒店 — 魚尾獅 這一帶. 近年又有勞小熊維尼對中國企業/香港的打壓和監管, 又更多中國大企業 / 香港金融業 把據點移過來了.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oosFzG3zaHxDAQ_RJ9kwQ.png" /><figcaption><a href="https://news.pts.org.tw/article/447972">https://news.pts.org.tw/article/447972</a></figcaption></figure><p>不過這邊就沒啥下班生活了, 畢竟地方小, 就是個城市生活. <br>以工時排名來看, 比台灣還捲 xdd 聽說一些中資企業到了新加坡還搞 996 惡習, 實在是… 不過也可以很明顯看出高工時國家高度集中在亞洲, 捲真的是亞洲人通病..</p><p>單就就業環境來看, 新加坡是比渥太華好很多的一個城市.<br>不過如果考量到下班後的生活, 可能就見仁見智了!<br>喜歡城市生活的, 下班後泡個酒吧 坡坡會比較方便.<br>喜歡大自然的, 渥太華會是個好地方.</p><h4><strong>[生活育樂開銷]</strong></h4><p>## 食 ##</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjlSBqf5URLmDCZ6MTplew.png" /></figure><figure><img alt="外食又不想花太多錢, 速食會是好朋友" src="https://cdn-images-1.medium.com/max/1024/1*CveybIqXpV0-wO5-2vwt1w.png" /></figure><p>加 : <br>地廣人稀, 中午如果還要去外面買還得開車一段路, 不是很方便.<br>基本上都是要帶便當當午餐, 每天中午就是大家的廚藝大比拼. <br>上餐廳的話稅制會依照不同省份而略有不同, 在 Ontario 會有 13 % 另加服務生小費 15~20% 不等, 所以普通一餐吃下來其實並不便宜. <br>如果不想做飯又不想花太多錢, 速食店會是好朋友, 這邊有很多台灣沒有的速食餐廳可以選擇 ( A&amp;W / Wendys / Harveys / Five Guys / Teco bell .. etc) <br>速食一餐大概可以 15 加幣解決, 如果是去一般普通餐館, 含稅跟服務費可能就會花到 30–40 加幣.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*YIBSiJkfcFYMLvb358mLhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9KLBbO_lM0d_sI-b.jpg" /></figure><p>坡 : <br>剛好公司有提供免費午餐, 所以這部分就沒太多開銷. 坡的速食店跟進餐廳費用也跟加拿大花費差不多, 就略過不提. 不過一般時候多數外食的選擇是去類似台灣的美食街, 又稱 Hawker Centre, 正常一餐可以控制在 15 新幣以內.</p><p>總體來看, 在加拿大的生活, 因距離與作息影響, 多數是自行做菜. 花費的是買菜錢跟時間. <br>在新加坡生活, 步調節湊快, 多數是在 hawker centre 快快解決閃人. 所以少了點做菜樂趣. 吃飯也少了點 enjoy 的成分.</p><p>## 住 ##</p><p>加 : <br>北美主要又以 house (獨棟) town house (連排) condo (公寓) 三種形式為主<br>一人的話不用想太多, 在沒有其他分母情況下, 大概只有 condo 的 studio 可以選. 在渥太華行情大概會是 2000~2500 加幣. 不過這裡的房子大小都比亞洲大上不少, studio 會是一廳一房一衛. 兩人住其實也不會太擠.</p><p>坡 :<br>多虧了疫情造成的通膨跟總加速師帶來的外來就業人口, 2023 平均租金較疫情前漲幅高達 52% !!!! 沒啥好講, 貴到靠北. <br>這邊房子又以 HDB (政府組屋) / Condo (私人公寓) 兩種形式為主. <br>ㄧ人來看基本上 Studio 不用想, 一個月沒 4000 新幣大概租不到. 所以只能以家庭式的分租為主. HDB 會比 Condo 便宜一些, 不過隨大環境影響, 價格都扯到誇張. Common room (雅房) 可以喊到 1500 SGD, Master room (套房) 可以喊到 2000 SGD.</p><p>## 行 ##</p><p>加 :<br>地廣人稀, 公共交通也不是很方便, 基本上沒車跟沒一樣出不了門. 所以買車養車會是必需品.</p><p>坡 :<br>買車前要先買 “擁車證”, 據說現在行情是 13W SGD, 有了車證才可以買車. 所以非家裡有礦, 在坡買車不是很划算. 多數人是以 MRT 通勤, 票價大概台北捷運 2 倍吧.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c920c4d1170" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[筆記] 淺入淺出 Istio (1) — 架構簡說]]></title>
            <link>https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E6%B7%BA%E5%85%A5%E6%B7%BA%E5%87%BA-istio-1-%E6%9E%B6%E6%A7%8B%E7%B0%A1%E8%AA%AA-a8d6aaf6977d?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8d6aaf6977d</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[service-mesh]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Sat, 12 Dec 2020 07:55:58 GMT</pubDate>
            <atom:updated>2020-12-12T08:01:39.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] 淺入淺出 Istio (1) — 架構簡說</h3><p>自從踏入了 k8s 深淵後，才逐步了解從傳統 Monolithic(單體式架構)的服務要轉成 Micro Service(微服務)有許多的架構設計問題需要去思考。而即便順利的將服務搬到 k8s 上，萬一之後在上面的 service 越長越多，系統越來越龐大，在各 service 間網路控管、系統的監控便會造成困難。</p><p>好在 Istio 的出現，相當方便幫助因 k8s 而造成的新時代產物 — DevOps 工程師們解決了以上煩惱。而此篇以一個初入 Istio 不久的使用者(剛出新手村!?)角度，記錄一下踏入這坑的雜記，若有誤希望不吝指教。</p><h3>What’s Istio?</h3><ul><li><strong>Istio is a service mesh.</strong><br>這句話有點繞口，但須先理解的是何為 Service Mesh?<br>這邊簡單說一下(<a href="https://www.redhat.com/en/topics/microservices/what-is-a-service-mesh">想更深入可看這篇</a>)，在 Microservice 的架構下，各個 Service 間的溝通可能需要不同的實作方式(流量控管、連線數、效能監控等等你常見的網路機制)會變得很複雜，原先可能需要開發者們在程式內實作，但有了 service mesh 就不用了!<br>Service Mesh 的基本概念就是在每個 pod 旁增加一個 side car，把關於流量網路的雜事都抽離出來，接下來所有經過 pod 的 request 都是經由 side car 轉導，大大減輕開發者們的負擔。<br>而 Istio 其實就是 Service Mesh 的一種實作，這部分應該是百家爭鳴拉，常見的還有 Linkerd ，但筆者用 Istio 就是了。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dcDb4hSl7C6AQeewrsw9A.png" /><figcaption>Service Mesh</figcaption></figure><ul><li><strong>Implement network mechanism.</strong><br>上點已略為提到，各個 pod 間的網路雜事，甚至是 API gateway 等設定，總之關於 “網路” 的通通抽離出來，Istio 統一做管理與設定，讓開發者能更能專注於功能的開發上。</li><li><strong>Integrate with many observability tools.</strong><br>上面已了解到 Service Mesh 是透過 side car 來轉發 request 的，所以當然也記錄了許多 request/response 等相關 metrics。而 Istio 也順帶整合了許多第三方的觀測工具(e.g. Prometheus, Kiali, Grafana, etc.)</li><li><strong>Handle microservice challenges.<br></strong>承開頭所提及的，在 microservice 架構下當 service/pod 一多，要去管控各個 service 間的網路連線是非常頭痛的，下圖是 Twitter 所公布其系統的 架構圖(<a href="https://blog.twitter.com/engineering/en_us/a/2013/observability-at-twitter.html">想看原文點這</a>)，看了就覺得頭痛了吧! 這也是 microservice 架構常見的棘手難題之一，好在 Istio 能幫助減輕這問題。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFxLusjK12MIdQG20VJoIg.png" /><figcaption>Twitter’s system</figcaption></figure><h3>Architecture</h3><p>這邊以循序的方式說明下 Istio 的架構。</p><ul><li>在 K8S 上，若沒有 Service Mesh 的幫助，一般 Service/Pod 間可能需如下圖，自行去實作 Service 間的網路機制。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffF08XEHFRtqGaUQY5_baw.png" /></figure><ul><li>而若套用 Service Mesh，便會在各個 Pod 旁 Inject side car，而上層則會多一個 control plane，開發者可以透過一些指令/設定去統一管控 Service/Pod 間的網路機制。</li><li>這邊提醒一點，下圖的部分其實嚴格說來有點畫錯(但沒辦法，Istio 官方架構圖也這樣畫(攤手)，應該是<br>=&gt; 對 Pod 去 Inject side car<br>=&gt; 對 Pod 去 Inject side car<br>=&gt; 對 Pod 去 Inject side car<br>而不是對 Service，因為一個 Service 下可能有很多個 Pod。<br>舉例而言有一個 Rest API 的服務在 K8S 上，但有很多 Pod 為不同 Version，以 Microservice 架構來看，我們可將這 Rest API 視為一個 Service，但其之下其實是有很多 Pod 代表不同 Version。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ9n80Pf9ssVjyP_az5-uw.png" /></figure><ul><li>而 Istio 的架構可以看出與上圖頗為相似，在各個 Pod (但 Istio Document 上還是畫 Service 這邊很容易混淆)旁會有個名為 istio-proxy 的 side car，來幫助我們轉發 request、蒐集資訊等。<br>而 Control Plane 層則會有個名為 istiod 的 Pod 來幫助我們控管服務。<br>而 istiod 中間的 Pilot、Citadel、Galley 等細節有興趣的可以啃這 (<a href="https://istio.io/latest/zh/docs/ops/deployment/architecture/">中文版 Istio Doc</a>) <a href="https://istio.io/latest/docs/ops/deployment/architecture/">英文版的相同頁面</a>就不知道為何沒提到這段。不過這幾個元件應該有個概念就可以了，一般 Istio 操作上應該是不會遇到它們。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pamQdkN2AMmd--tiXdRGww.png" /></figure><ul><li>最後來對比一下 Istio 與一般 K8S 在 Pod 溝通機制上的差異。在原生 K8S 上，各 Pod 間的溝通是透過 Node 上的 kube-proxy(它會紀錄其他節點上的 Pod iptables)並做 request 轉發。<br>而在 Istio 上，則不用透過原生機制，因為每個 Side car 就是個 proxy，所以直接幫你做 request 轉發。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YA8ZK8d4fWiBLorTvzwwJA.png" /></figure><h3><strong>Reference</strong></h3><ul><li><a href="https://blog.twitter.com/engineering/en_us/a/2013/observability-at-twitter.html">Observability at Twitter</a></li><li><a href="https://www.redhat.com/en/topics/microservices/what-is-a-service-mesh">What is a service mesh?</a></li><li><a href="https://istio.io/latest/zh/docs/ops/deployment/architecture/">架构</a></li><li><a href="https://istio.io/latest/docs/ops/deployment/architecture/">Architecture</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8d6aaf6977d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E6%B7%BA%E5%85%A5%E6%B7%BA%E5%87%BA-istio-1-%E6%9E%B6%E6%A7%8B%E7%B0%A1%E8%AA%AA-a8d6aaf6977d">[筆記] 淺入淺出 Istio (1) — 架構簡說</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[筆記] 實作分散式計分系統(四) : Build up an interactive CLI with Cobra]]></title>
            <link>https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E5%9B%9B-build-up-an-interactive-cli-with-cobra-1b4b60c3094c?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b4b60c3094c</guid>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[cobra]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 07:50:53 GMT</pubDate>
            <atom:updated>2020-02-09T07:50:53.957Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] 實作分散式計分系統(四) : Build up an interactive CLI with Cobra</h3><p>Cobra 是 Golang 中相當好用的一套件 ，能幫助我們建立屬於自己的command ，而且非常好上手，以下將直接使用 Cobra 來建立 CLI 去呼叫 <a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%B8%89-grpc-and-protobuf-f8edd3d1e981">上篇</a> 建立的 RPC function。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QzKtVGlafB9NzlV8.png" /></figure><h4>Step1:</h4><p>安裝所需套件。</p><pre>go get -u github.com/spf13/cobra/cobra</pre><h4>Step2:</h4><p>在 client 資料夾下初始化 cobra 專案 cobra init [pkg-name]<br>這邊要小小注意的是 pkg-name <strong>僅僅代表該系列的 CLI 名稱</strong>，一開始我以為像是常用的 :<br>git add . git commit -m &quot;xxx&quot; 的 pkg-name 就會是 git ，結果搞錯(冏)<br>如果想要像 git add . 這樣的效果 ，需要在 rootcmd 下而外綁定 git ，然後再綁定 add 在 git 下這樣的階層式設定。</p><p>而這邊一開始先別那樣複雜，先用個 CLI 雛型 <br>new [name] : 新增棒球比賽<br>list [dbIP] [dbPort] : 獲取比賽列表(可指定 DB Node)<br>add [id] [team] [round] [add]: 為指定比賽分數新增得分<br>score [id] [dbIP] [dbPort] : 獲取指定比賽分數(可指定 DB Node)</p><p>所以於 client 資料夾下執行</p><pre>cobra init --pkg-name game<br>cobra add new<br>cobra add list<br>cobra add add<br>cobra add score</pre><p>此時資料夾結構</p><pre>client<br>│   ├── cmd<br>│   │   ├── add.go<br>│   │   ├── list.go<br>│   │   ├── new.go<br>│   │   ├── root.go   <br>│   │   └── score.go<br>│   ├── LICENSE       // 自動生成的 沒用到可以刪掉<br>│   ├── clienNode.go  // 先建立一個空的 clientNode.go 待會會用到</pre><h4>Step3:</h4><p>此時先來看一下程式結構，簡單以 root.go list.go 做說明<br>(以下省略了部份程式碼，僅以大致架構做說明)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/204c76149f55950d818ba2b3892e4b20/href">https://medium.com/media/204c76149f55950d818ba2b3892e4b20/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/281fb36608f25a6c251a0b6f098640e4/href">https://medium.com/media/281fb36608f25a6c251a0b6f098640e4/href</a></iframe><p>這邊不難理解，其實就是以階層式包裝的，首先我們在 root.go 中定義 game command，並於 list.go 中定義 list command，並將其綁訂到 game command 中。<br> (但我認為在 rootCmd 裡設定 game 並沒有特別用處，因為它代表不是 command 會變成 game list，這時 command 還是 list，如果不了解的看下面 demo 圖會清楚些。)</p><p>而基礎的初始化做好後可以先來試用一下， 調用方法也很簡單，僅須呼叫 root.go 下的 Execute() 即可，所以於下 clientNode.go 呼叫 Execute()</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fec86fc876ddf77d3df65f9196cac048/href">https://medium.com/media/fec86fc876ddf77d3df65f9196cac048/href</a></iframe><p><strong>demo1</strong> : 執行 clientNode.go 並帶入參數 --help <br>會自動秀出相關的操作說明</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*ERf4yvJvQL4dJP77yAIyeQ.png" /><figcaption>--help</figcaption></figure><p><strong>demo2</strong> : list<br>會執行 list.go 中對 list 的操作 fmt.Println(“list called”) <br>但這邊也是我認為 rootCmd 設定並沒有特別用處的原因，因為我們帶入的 command 並不是 game list 而只是 list ，這點我個人認為 Cobra 的設計並不是太直觀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nQsHvAbwQ5XccLXYteZgcQ.png" /><figcaption>list</figcaption></figure><h4><strong>Step4</strong>:</h4><p>這一步會跳的比較多一點，但搭配程式碼應該不難理解</p><ol><li>將剛才 client/cmd 下的所有 go file 全部加進 cmd.go 中。</li><li>將 rootCmd 設為空，然後在綁定 gameCmd (這樣才能達到上述<br> game list 的效果)。</li><li>在 init()中加入各 command 所需的參數。</li><li>於 scoreCmd listCmd addCmd newGameCmd 實做呼叫 RPC function 的細節。<br>new [name] : 新增棒球比賽<br>list [dbIP] [dbPort] : 獲取比賽列表(可指定 DB Node)<br>add [id] [team] [round] [add]: 為指定比賽分數新增得分<br>score [id] [dbIP] [dbPort] : 獲取指定比賽分數(可指定 DB Node)</li></ol><p>另外在 <strong>demo2 </strong>的部份可以看到 Cobra 這樣預設的 CLI 架構基本上還是必須去執行一個 go file 然後帶入 command 參數，像是:<br>go run clientNode_demo.go list</p><p>個人不太喜歡這樣子的作法，因為每操作一次就要去執行一次clientNode.go。</p><p>這邊希望能以 <strong>交談式的循環界面</strong> 呈現。而可以發現 <br>go run clientNode_demo.go list 這樣子的呼叫方式是將欲執行的 command 帶入 os.args 中的，所以方法也很簡單在 clientNode.go 的部份改成以循環的方式去讀取 stdin ，並且每次讀取到 stdin 時抽換掉 os.args 即可 ，所以以下最後一步。(當然這作法有點暴力 ，或許有更適合的方式)</p><p>5. 更改 cliendNode.go 呼叫 cmd.go - Execute() 的方式，改為循環式讀取 stdin，每讀取一次再去呼叫一次 Execute()，並抽換os.args 。</p><p>6. 最後展示下成果，client 端能以 <strong>交談式的循環界面 </strong>來去呼叫 RPC function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zMNCWhKLSTugL6qSvy3Nhg.png" /></figure><p>實做解說的部份在這告個段落，而更多細節處理的部份 (e.g. 包成 container 之類)可參考 <a href="https://github.com/amosricky/Simple_Distributed_System">Simple_Distributed_System</a> ，完整的專案程式都已經放在那 <br>下方為此部份 code 與資料夾結構 。</p><pre>├── client<br>│   ├── clientNode.go<br>│   └── cmd<br>│       └── cmd.go</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ef20b76cb673aeda76d977ef66dcf95/href">https://medium.com/media/4ef20b76cb673aeda76d977ef66dcf95/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/455d386c0cb32657304b7a0ef4260430/href">https://medium.com/media/455d386c0cb32657304b7a0ef4260430/href</a></iframe><h4>Reference</h4><ul><li><a href="https://github.com/spf13/cobra">GitHub - spf13/cobra: A Commander for modern Go CLI interactions</a></li><li><a href="https://github.com/amosricky/Simple_Distributed_System">amosricky/Simple_Distributed_System</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b4b60c3094c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E5%9B%9B-build-up-an-interactive-cli-with-cobra-1b4b60c3094c">[筆記] 實作分散式計分系統(四) : Build up an interactive CLI with Cobra</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[筆記] 實作分散式計分系統(三) : gRPC and Protobuf]]></title>
            <link>https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%B8%89-grpc-and-protobuf-f8edd3d1e981?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8edd3d1e981</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[rpc]]></category>
            <category><![CDATA[protobuf]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[grpc]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Fri, 07 Feb 2020 03:50:10 GMT</pubDate>
            <atom:updated>2020-02-07T03:50:10.969Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] 實作分散式計分系統(三) : gRPC and Protobuf</h3><p>在建立 gRPC Server 前，須先了解 Protobuf, 而其兩者都是 Google 的產物。<br>這邊並不會詳細介紹它們的詳細概念, 這類的筆記網上已有很多, 所以只做個簡介並紀錄如何使用它們搭建 gRPC Server。</p><h4>Protobuf</h4><p>Protobuf 是 Protocol Buffers的簡稱，用於描述一種輕便高效的結構化數據存儲格式，簡單說就是能以<strong>一份文件</strong>定義格式，然後能方便直接轉成各類語言的資料型態，而以本範例來說能直接轉譯成 golang struct，目前已能支援多種語言，詳細可參考<a href="https://developers.google.com/protocol-buffers">官網</a>。</p><h4>gRPC</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*ZVirmBhtvTcIPYSqo9gXAA.png" /><figcaption><a href="https://grpc.io/docs/guides/">https://grpc.io/docs/guides/</a></figcaption></figure><p>gRPC 的概念其實很直覺，就是透過 Protobuf 定義出來的資料結構，不只代表格式，同時也代表你伺服器的接口。最大好處其背後是以 http2 傳遞，比起一般走 http/https 的 Restful API 不僅傳輸效率上快上許多，也不用另外寫文件。Client 端與 Server 端只要遵照定義出來的資料格式傳遞/實作(可參考上圖)，API 就能執行。</p><h3>How to use Protobuf</h3><h4>Step1 :</h4><p>安裝所需套件。</p><pre>go get -u <a href="http://github.com/golang/protobuf/%7Bproto,protoc-gen-go">github.com/golang/protobuf/{proto,protoc-gen-go</a>}</pre><h4>Step2:</h4><p>創建資料夾並定義 .proto 文件。</p><pre>pb  // 擺放 Protobuf 文件<br>└── game.proto</pre><h4>Step3:</h4><p>message 用來定義 RPC function 之 Request/Response<br>這邊共定義了 4 個 function</p><p>• <strong>GetScore </strong>: 獲取指定棒球比賽得分數<br>• <strong>PutScore </strong>: 對指定比賽新增分數<br>• <strong>GetGameList</strong>: 獲取所有棒球比賽清單<br>• <strong>PostNewGame</strong>: 新增棒球比賽</p><p>並掛到 rpc Server - ServiceServer 上</p><p><a href="https://developers.google.com/protocol-buffers/docs/proto3">語法文件</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23264458091d9b266554e4ac0915a438/href">https://medium.com/media/23264458091d9b266554e4ac0915a438/href</a></iframe><h4>Step4 :</h4><p>進入 /pb 資料夾，然後執行下列指令</p><pre>protoc --go_out=plugins=grpc:. *.proto</pre><p>可看到 ./pb 生成 game.pb.go</p><pre>pb<br>├── game.pb.go<br>└── game.proto</pre><h3>How to use gRPC</h3><h4>Step1:</h4><p>安裝所需套件</p><pre>go get google.golang.org/grpc</pre><h4>Step2:</h4><p>建立對應資料夾與 go file</p><pre>├── pb<br>│   ├── game.pb.go<br>│   └── game.proto<br>├── conf<br>│   └── app.ini<br>├── setting<br>│   └── setting.go<br>├── server<br>│   └── serverNode.go<br>├── client<br>│   ├── client_demo.go</pre><h4>Step3:</h4><p>編輯 conf/app.ini 與 setting/setting.go <br>(這把 configuration 放到檔案裡比較好維護不是必須步驟，只是個人習慣把 configuration 放到檔案裡比較好維護)</p><p>這邊是以 “github.com/go-ini/ini” 套件將 conf/app.ini 轉為結構實體變數，能方便在後續使用到它們。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7a6601f0e5f4a89fd10a171488afaff/href">https://medium.com/media/e7a6601f0e5f4a89fd10a171488afaff/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/206e36fcfbcc63731631cd245b4896c9/href">https://medium.com/media/206e36fcfbcc63731631cd245b4896c9/href</a></iframe><h4>Step4:</h4><p>這邊是本篇較重要的地方，首先宣告了 server struct{} ，並依照先前在 game.proto 宣告過方法與 message 將四個同名 function GetScore PutScore GetGameList PostNewGame 實作於 server struct{} 。</p><p>以 GetScore 為例，已於 game.proto 定義此 RPC function 所需的參數 - GetScoreRequest 與返回格式 - GetScoreReply</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36465213ef14ba6d0bd0942f946d5fbf/href">https://medium.com/media/36465213ef14ba6d0bd0942f946d5fbf/href</a></iframe><p>故在 GetScore function 中接收的參數需為 GetScoreRequest ，最後也以 GetScoreReply 返回。而若 GetScore 執行過程有錯，gRPC 可將 error 帶在第二個參數返回。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c0247e5fd8449e2b0c2c900c1e5043d/href">https://medium.com/media/1c0247e5fd8449e2b0c2c900c1e5043d/href</a></iframe><p>再來直接看到完整的 serverNode.go ，連接資料庫的部份定義了 mongoDB() 並帶入 url 與 port 來去連接指定的 mongoDB ，在 GetScore PutScore GetGameList PostNewGame 都有調用到此方法。當然在一般 monolithic system 而言資料庫會保持連線，不會每執行一次服務就重新去連線一次，而這邊會這樣設計是因為本系統有 3 個 Replica Set Node，3 個 node 都能被 Read ，但只有 Primary Node 能執行寫入動作 (Write)。</p><p>所以在 GetScore GetGameList 方法中能讓使用者指定資料庫 node 去做讀取，而 PutScore PostNewGame 則連接於 conf/app.ini 內的預設 Primary Node)。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c38319916b44d5d47c81c61fc014e984/href">https://medium.com/media/c38319916b44d5d47c81c61fc014e984/href</a></iframe><p>最後則於 main function 啟動 gRPC Server 並監聽tcp port 50051 。</p><h4>Step5:</h4><p>完成 Server 端後再來是 Client 端的部份，這部份就簡單許多 。以新增棒球比賽 PostNewGame 為例，先透過 grpc.Dial() 去連接已啟動的 gRPC Server，在用回傳的 conn 去呼叫 PostNewGame ，當然別忘了要以 game.proto 定義的格式帶入參數 - PostNewGameRequest 。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9237a39b332adb5b9215d1db190fa440/href">https://medium.com/media/9237a39b332adb5b9215d1db190fa440/href</a></iframe><h4>Step6:</h4><p>最後來看下目前成果 ，在此前已先啟動 Replca Set 與 gRPC Server，接著再執行 client_demo.go 去新增一筆名為 “Test0109_3”的棒球比賽。若新增成功回傳的結果會是該筆資料的 objectID 。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ydpxPnRPHT7Xdn83yLKxCQ.png" /></figure><p>當然如果不用其他 RPC Tool 的前提下，那每次 client 端都要透過以上這樣的 client_demo.go 去呼叫服務未免有些麻煩，所以下篇將介紹 Cobra，說明如何將其包裝成 CLI 來方便操作。</p><h4>Reference</h4><p><a href="https://grpc.io/docs/guides/">Guides</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8edd3d1e981" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%B8%89-grpc-and-protobuf-f8edd3d1e981">[筆記] 實作分散式計分系統(三) : gRPC and Protobuf</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[筆記] 實作分散式計分系統(二) : Replica Set in Container]]></title>
            <link>https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%BA%8C-replica-set-in-container-5759b1b4cd5?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/5759b1b4cd5</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[sharding]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[replica]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Tue, 04 Feb 2020 17:24:23 GMT</pubDate>
            <atom:updated>2020-02-05T03:13:29.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] 實作分散式計分系統(二) : Replica Set in Container</h3><p>記錄如何建立 mongoDB Replica Set，並且利用 docker-compose 以 container 方式取代 host ，以模擬實際分散式資料庫。而在實際建立 Replica Set 之前須先前情提要下 Replica Set 與 Shard Cloud 的差異，接著在說明 Replica Set 的建立方式。</p><h3>Replica Set</h3><p>在網路上搜尋 mongoDB, distributed system 時應該時常會出現 <strong>Replica</strong> 與 <strong>Sharding </strong>等相關結果，而他們都是分散式資料庫的實現方式，但應用上確有很大的差別。</p><p>Replica Set 的架構方式其實有多種變形方式，這邊主要介紹最典型的架構，主要由三個節點構成，如下：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*9YeJ1TAPT5Sco73wKWvsBA.png" /><figcaption>Replica Set 典型架構</figcaption></figure><p>每個節點 (host)都建立了 mongoDB 服務，正常情況 User/Application 僅對 Primary 節點進行 Read/Write，資料會自動複製 (Replication) 到另外兩組 Secondary 節點，以達到資料備援。Secondary 僅提供 Read，故若 Client 端只須讀取資料，能對每個節點直接讀取，其結果會是一致的。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*N6KrWD6mAzOH4aIHRaiB8A.png" /><figcaption>Replica Set - Heartbeat</figcaption></figure><p>而這些節點間畢竟還是以網路進行溝通的，需確保彼此間是否還存活，這些節點透過 Heartbeat (每隔一段時間試探節點是否存活的方式) 檢測狀態，正常的情況每 2 秒會送出 Heartbeat，若是超過 10 秒沒有回覆，那就被視為故障。若故障的節點為 Primary 則會從 Secondary nodes 中選出一個來取代。<br>(詳細可參考<a href="https://docs.mongodb.com/manual/core/replica-set-secondary/">此篇</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*xFEPZsCHdy84fxhjiWTDiw.png" /><figcaption>Primary Election</figcaption></figure><h3>Sharding</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*RQUr1kHAM7b0_wLWrtFwEQ.png" /><figcaption>Sharding 架構</figcaption></figure><p>Sharding 主要是以分片的方式儲存資料，有Shard/Config /mongos 三種節點，其對應功能為</p><ul><li><strong>mongos</strong> : 負責提供 Client 端去連接資料庫。</li><li><strong>Sharding</strong> : 儲存 Shared data 的分片。</li><li><strong>Config Servers</strong> : Sharding 的 metadata 與設定檔，讓 Client 知道該怎麼走到正確的 Shard 去讀寫資料。</li></ul><p>而 Config Servers 與 Sharding 又須以 Replica Set 的方式建置。所以 Sharding 算是 Replica Set 的進階應用。</p><h3>Replica Set in Container</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Uk6CDtvOCpTlvVD.jpg" /></figure><p>這邊依步驟來做說明，目標是建立一個名為 RS 的 Replica Set，並分別綁定port <strong>27041</strong>/<strong>27042</strong>/<strong>27043</strong></p><h4>Step1</h4><p>有兩個檔案，server_node.yml 與 replica/config/mongod.yml (注意路徑)</p><pre>## replica/config/mongod.yml<br>net:<br>  bindIpAll: true<br>storage:<br>  engine: wiredTiger<br>  wiredTiger:<br>    engineConfig:<br>      cacheSizeGB: 0.1</pre><p>mongod.yml : 為 mongoDB 之設定檔，而此設定檔主要是指該 mongoDB能綁定任何形式的 ip (ipv4 &amp;&amp; ipv6)。Storage engine 值 default 即為 wiredTiger ，或是可設定為 inMemory，這部份就沒深入研究，有興趣的可參考<a href="https://docs.mongodb.com/manual/reference/configuration-options/">官方Doc</a></p><pre>## server_node.yml<br>version: &#39;3&#39;<br>services:<br>  rs1:<br>    image: mongo:4.2<br>    container_name: rs1<br>    ports:<br>      - &quot;27041:27041&quot;<br>    command: mongod --replSet RS --port 27041 --dbpath /data/db --config /resource/mongod.yml<br>    volumes:<br>      - ./replica/config/mongod.yml:/resource/mongod.yml<br>      - ./replica/data/rs1:/data/db<br>   <br>  rs2:<br>    image: mongo:4.2<br>    container_name: rs2<br>    ...</pre><p>server_node.yml : 設定 rs1, rs2 , rs3 三個 mongoDB container</p><h4>Step2</h4><p>接下來，就可以建立執行容器。</p><pre>$ docker-compose -f docker-compose-replica-set.yml up</pre><h4>Step3</h4><pre>$ mongo 127.0.0.1:27041</pre><p>在確認 3 個 container 都跑起來後透過 mongod 指令進入 rs1, 並帶入以下Replicat Set 設定。</p><pre>cfg = {<br>    &quot;_id&quot;: &quot;RS&quot;,<br>    &quot;members&quot;: [{<br>        &quot;_id&quot;: 0,<br>        &quot;host&quot;: &quot;rs1:27041&quot;<br>    },<br>        {<br>            &quot;_id&quot;: 1,<br>            &quot;host&quot;: &quot;rs2:27042&quot;<br>        },<br>        {<br>            &quot;_id&quot;: 2,<br>            &quot;host&quot;: &quot;rs3:27043&quot;<br>        }<br>    ]<br>};<br>rs.initiate(cfg);</pre><p>印出 ok: 1 就設定完成。</p><p>最後也可透過 rs.status() 來查看狀態。</p><h4>Demo :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gqh3RT99ZKI9fKDAX3-YLg.gif" /></figure><h4>Source Code</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de8c728ff82002beacd67dfec4586cba/href">https://medium.com/media/de8c728ff82002beacd67dfec4586cba/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/740edf84e28f4377ea667b78825cad69/href">https://medium.com/media/740edf84e28f4377ea667b78825cad69/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d8d93d7c8f6c416bac6f1c3a1e193f5/href">https://medium.com/media/8d8d93d7c8f6c416bac6f1c3a1e193f5/href</a></iframe><h4>連線常見問題</h4><p>若使用 mongod script 去連接 db 應該是不會有問題</p><pre>mongo 127.0.0.1:27041</pre><p>但若使用 golang 套件去連接 (e.g. go.mongodb.org/mongo-driver/mongo)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88aa4d97d0c1b5acf5faa4564e704993/href">https://medium.com/media/88aa4d97d0c1b5acf5faa4564e704993/href</a></iframe><p>可能會發生像是 <br>error: dial tcp<br> error: context deadline exceeded</p><p>之類的錯誤訊息, 主因是若使用套件去連接 mongodb://127.0.0.1:27041<br>是去連接 Replica Set, 而 mongoDB driver 會去嘗試 server discovery 所有的 node。</p><p>而因為 Replica Set 的都是在 docker container 內, 而container 彼此間是以 container name (e.g. rs1, rs2) 來相互連接的, Docker host 上是認不到 127.XXX 之類的 ip 的, 所以才會發生錯誤。</p><p>此時若只須連接單一 mongoDB node, 只須將 url 加上 connect 參數即可。</p><pre>mongodb://127.0.0.1:27041/?connect=direct</pre><ul><li><a href="https://docs.mongodb.com/manual/replication/">Replication - MongoDB Manual</a></li><li><a href="https://ithelp.ithome.com.tw/articles/10227851">[資料庫]使用 Docker 構築不同 MongoDB 架構 (三) - Replica Set - iT 邦幫忙::一起幫忙解決難題，拯救 IT 人的一天</a></li><li><a href="https://stackoverflow.com/questions/56393513/docker-and-mongo-go-driver-server-selection-error">Docker and mongo-go-driver &quot;server selection error&quot;</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5759b1b4cd5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%BA%8C-replica-set-in-container-5759b1b4cd5">[筆記] 實作分散式計分系統(二) : Replica Set in Container</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[筆記] 實作分散式計分系統(一) : 基礎架構]]></title>
            <link>https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%B8%80-%E5%9F%BA%E7%A4%8E%E6%9E%B6%E6%A7%8B-e3ba68541002?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3ba68541002</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[replica]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Mon, 03 Feb 2020 17:02:44 GMT</pubDate>
            <atom:updated>2020-02-04T02:08:45.844Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] 實作分散式計分系統(一) : 基礎架構</h3><p>為了精進一下分散式系統的概念，在研讀雜七雜八的資料後決定實作個簡易的分散式系統，並將其紀錄下來。本系統是棒球比賽計分系統，並善用 mongoDB 的 Replica Set，讓資料同步於多個 host ，達到分散式儲存的效果。Client 端與 Server 端之間以 RPC 方式呼叫，但為求方便設計成 CLI 指令溝通方式，以方便 Client 端操作。</p><h4>起源</h4><p>此系統的設計靈感主要來自 Doug Terry ，在 <a href="https://mwhittaker.github.io/consistency_in_distributed_systems/1_baseball.html">2013 CACM article, Replicated Data Consistency Explained Through Baseball</a> 提出用棒球賽與參與人員來解釋各種 Consistency Model，而剛好也有人對 Doug Terry 舉出的例子做了更淺顯易懂的說明 (可參考 reference)，於是便決定以此案例為系統此案例為系統雛型架構。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*EN63W0vYaQ1D2Q0sKWDtaA.png" /><figcaption>Doug Terry 計分系統架構</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*6u9Q_oAQL8Qob-n4x_i49w.png" /><figcaption>棒球比賽計分</figcaption></figure><p>以上圖來說，Client 端只會對 Primary Server 進行 Write 操作，而 Primary Server 會將資料同步到 replica server 上，所以 Client 端能從任何 replica server 獲取資料 。</p><h4>架構說明</h4><p>故以上述案例為本系統之雛型，設計並實作一棒球比賽計分系統，主要架構如圖 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*8Xcm1BtbAqEYN94YOh6gpg.png" /><figcaption>系統架構圖</figcaption></figure><p>每一個 node 皆為 container node，方便部屬也方便管理。而要注意的是實務上每個 node 皆可部屬在不同的 host 上，遠端的 Client node 只要連線的到 Server node 便可對棒球比賽進行操作。而 Server node 也只要連線的到 Replica set node 便可回應來自 Client node 的需求。</p><p>但以 replica set 來說，為確保資料備份之安全性，通常會將 replica set 中的 node 部屬到不同 host 上，這邊為求方便才會都放在 localhost 上。</p><p>功能上來說一樣是以 Client 端能對棒球比賽進行操作為主 (e.g. 創建棒球比賽、指定局數增加分數、瀏覽比賽列表 ...)，但多了以下特點 :</p><ul><li><strong>Client 端能透過 RPC 方式對比賽資訊進行存取。</strong></li><li><strong>為方便 Client 端操作，將 RPC function 轉化為 CLI 指令方式呼叫。</strong></li><li><strong>Server 端為 gRPC Server，處理來自不同 Client 端的 RPC Request 並對 mongoDB 進行 Read/Write。</strong></li><li><strong>mongoDB 透過 Replica Set 來實現分散式資料庫，能自動將 Data 備份至所有 node 上。</strong></li></ul><p>涉及到的工具有..</p><ul><li><strong>Golang (gRPC) : Client 與 Server 間以 RPC 方式做溝通。</strong></li><li><strong>Golang (Cobra) : 結合 CLI 指令， 讓 Client 能以 Comand 方式執行操作。</strong></li><li><strong>mongoDB (replica set) : 透過 replica set 達到分散式資料庫儲存的效果。</strong></li><li><strong>protobuf : 協助定義棒球比賽之 struct。</strong></li><li><strong>Docker container : 用來方便部屬與執行各節點。</strong></li></ul><p>大致上的系統功能說明如上，下一篇會記錄以 Docker container 來建立 Replica Set 的方式與容易踩雷的地方。</p><p>完整代碼請參考 : <a href="https://github.com/amosricky/Simple_Distributed_System">Simple_Distributed_System</a></p><h4>Reference</h4><ul><li><a href="https://mwhittaker.github.io/consistency_in_distributed_systems/1_baseball.html">Consistency in Distributed Systems</a></li><li><a href="https://ithelp.ithome.com.tw/articles/10217086">Day 3 - 從Replica Server讀到的資料一定正確嗎? Data Replication and Consistency - iT 邦幫忙::一起幫忙解決難題，拯救 IT 人的一天</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3ba68541002" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E7%AD%86%E8%A8%98-%E5%AF%A6%E4%BD%9C%E5%88%86%E6%95%A3%E5%BC%8F%E8%A8%88%E5%88%86%E7%B3%BB%E7%B5%B1-%E4%B8%80-%E5%9F%BA%E7%A4%8E%E6%9E%B6%E6%A7%8B-e3ba68541002">[筆記] 實作分散式計分系統(一) : 基礎架構</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[雜紀]淺談AI人工智慧之現況]]></title>
            <link>https://medium.com/hobo-engineer/%E9%9B%9C%E7%B4%80-%E6%B7%BA%E8%AB%87ai%E4%BA%BA%E5%B7%A5%E6%99%BA%E6%85%A7%E4%B9%8B%E7%8F%BE%E6%B3%81-4d9c718221b2?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d9c718221b2</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Thu, 31 Oct 2019 08:26:57 GMT</pubDate>
            <atom:updated>2019-10-31T10:03:19.869Z</atom:updated>
            <content:encoded><![CDATA[<h3>[雜記] 淺談AI人工智慧之現況</h3><p>遙想幾年前大學時，&quot;大數據&quot;、&quot;Big Data&quot;等議題被炒得火熱，不管是在業界或是學界總能看到相關的職缺、競賽、課程紛紛興起。系上也開了 「資料探勘」還是「資料採礦」之類的課程，開始用 Python 接觸大數據第一課 — 尿布與啤酒。但時至今日，&quot;大數據&quot;這議題不知是人們忘了? 還是害怕想起來? 忘記這才是 AI 一切的根源 ，熱潮早已冷退，取而代之興起的是 AI 人工智慧 。從學生時期到現在出社會，親歷了這些變遷過程，以此篇紀錄一下個人淺見。</p><h3>關於 DM 、 ML 與 AL</h3><p>在廣泛的 Data Science 角度來看，這張圖可以做個簡單說明。<br>Data Mining(DM), Machine Learning(ML), Artificial Intelligence(AI) 三者其實是循序漸境的發展。簡單來說就是必須先有海量的 Big Data 來輔助進行 Data Mining , 接著從中獲取了一些 Rule 後再透過 Machine Learning 來 training 出有用的 model 。最後一步的 AI 白話一點來說則是指以上這些步驟都可以跳過，直接把 Big Data 餵入電腦就能自動產生有用的 pattern 和 rule ，這才是真正意義上的人工智慧。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q73VUOGmuthOx2JV.png" /></figure><h3><strong>目前的 AI 亂象</strong></h3><p>但放眼台灣近幾年，卻鮮少聽聞有甚麼蒐集 Big Data 後透過 Data Mining 進而創造價值的成功案例。大多數的例子，都只是利用簡單統計資訊，例如銀行透過信用卡刷卡資料，塞選出 25~45 歲為消費主力等之類簡單應用。但這類例子其實與實質上的 Data Mining 沾不上甚麼邊，充其量只能算是統計資訊。然而未見 Data Mining 發展成熟，時至今日卻更多的新創公司、甚至是一般企業推出 &quot;AI&quot;、&quot;智能&quot; 等相關產品或案例。以下為 google 隨意找的兩個案例。</p><h4>案例 A : &quot;偽智能&quot; AI 音箱 — 小米盒子</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*R8jW2jWJ31b5llogpPb2Cw.png" /></figure><p>這應該是個大家耳熟能詳的產品，但其實這東西實質上只能算是個 “ 偽智能” 的 AI 音箱。關鍵在於現今 “ 語義識別” 與 “中文判讀” 與期望應用上仍有段落差。 說真的，現在的人機對話什麼水平？也就加個鬧鐘，關個檯燈，除此之外連基本聊天應該都撐不到3輪，就已經聽不懂人話了。 Pattern 不夠，且人類語言本來就艱深晦澀，一樣的語句、不同的語調、不同的廠警都會有不同含意，這也是我認為目前 AI 在發展上所遇到的最大瓶頸。要讓機器能 “理解” 人類語言含意，且通過圖靈測試，以目前技術來看似乎還有段落差。</p><p>下圖為 小米音箱在展示時出的小插曲 <a href="https://tw.appledaily.com/new/realtime/20181130/1475654/">全文</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*ostQMvkrd6daUxKv-pMXgw.png" /></figure><h4>案例 B: &quot;AI&quot; 濫用亂象 — AI 乳篩助理 <a href="https://news.ltn.com.tw/news/life/breakingnews/2947919">全文</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*MO8TvKIGftd0y1fxk1F49Q.png" /></figure><p>以案例 B 來說，是目前最常見的問題 — &quot;AI&quot;一詞過度濫用。<br>在此例中，很明顯是透過 ML 建出判別可能腫瘤位置的 Model ，這是屬於機器學習與大數據的範疇。當然我們不能否認這些應用的價值所在，但很明顯，這並不是 AI 。就近幾年所見，好像甚麼東西應用上了一些數據分析技巧，就可以把 &quot;AI&quot; 兩個字冠上去，就像鍍了金一般，成為站在 AI 浪潮最新的應用或噱頭。</p><p>但要知道 ML 到 AI ，是還有一段落差的，但台灣業界和媒體貌似對 AI 的標準蠻寬容的 ? 能看清東西（圖像識別），能聽個聲音（語音識別），就能打著 AI 旗鼓四處宣揚。或許是這議題對大眾來說過新，又或者是在媒體與業界濫用的影響下，鮮少見到有人站出來質疑這類問題的。</p><h3>AI 該走的路與現實落差</h3><p>除了以上兩個案例之外，目前業界長打的 &quot;AI&quot; 應用不外乎 <strong>人臉識別、語音辨識 </strong>之類套套 tensorflow 或是 keras 等現有套件，改個參數再訓練個 model 就能拿出來賣，這其實是最大的癥結點。</p><p>AI 如果要有所突破或發展，其真正的價值在於如何有更好的演算法 or 方法來幫助我們更貼近 AI ，而不應是只單純利用現有套件來訓練類神經。現有的技術效果在哪 ?瓶頸在哪 ? 應該大家有目共睹，就拿 <strong>語意識別</strong> 這東西來說好了，要讓機器人懂人類在講甚麼應該要先做好 <strong>語意判讀</strong> 吧?</p><p><strong>語意判讀 </strong>這需求很簡單，就和 Youtube 一樣，隨便點開一個影片能即時轉成字幕，請問目前哪個影音網站能做到呢？如果連這個都還沒實現，那又談什麼 <strong>語義識別 </strong>呢 ?</p><p>但目前台灣業界真正在做演算法開發的應該屈指可數。不難想像是因為長期 cost down 結果下造成的，畢竟投入的研發成本不一定能看到成效，這也是現實上的一大困境。大多數的職缺仍是在現有套件 or 技術上加以應用，而無法突破，我想這是 AI 發展來說略為可惜的地方。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d9c718221b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hobo-engineer/%E9%9B%9C%E7%B4%80-%E6%B7%BA%E8%AB%87ai%E4%BA%BA%E5%B7%A5%E6%99%BA%E6%85%A7%E4%B9%8B%E7%8F%BE%E6%B3%81-4d9c718221b2">[雜紀]淺談AI人工智慧之現況</a> was originally published in <a href="https://medium.com/hobo-engineer">hobo engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Ricky筆記] 解決 Ubuntu 18.04 上 Skype 不能輸入中文問題]]></title>
            <link>https://rh-tw.medium.com/ricky%E7%AD%86%E8%A8%98-%E8%A7%A3%E6%B1%BA-ubuntu-18-04-%E4%B8%8A-skype-%E4%B8%8D%E8%83%BD%E8%BC%B8%E5%85%A5%E4%B8%AD%E6%96%87%E5%95%8F%E9%A1%8C-fc29ab5a0b06?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc29ab5a0b06</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[skype]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Fri, 18 Oct 2019 03:06:23 GMT</pubDate>
            <atom:updated>2020-02-07T05:22:53.111Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] Ubuntu 18.04 上 Skype 不能輸入中文問題</h3><p>一陣子沒更新, 剛好最近遇到這小問題, 筆記紀錄下....</p><p>在 ubuntu 上如果是透過 ubuntu software 下載安裝 skype 的 , 會發生無法輸入中文的囧境 ORZ .</p><p>造成主因是以這方式取得的 skype 是 snap 版本(Linux 多種平台可以共用的通用套件格式) , 而這版本貌似沒支持中文輸入！？(詳細原因不明)</p><p>1. 所以須去 <a href="https://www.skype.com/en/get-skype/">官網</a> 下載官方版本來用</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oYA44kWtHPgwp3srJ9sKMQ.png" /></figure><p>2. 注意在此下載的是 rpm 套件管理的安裝檔</p><p>所以如欲安裝在 ubuntu 上須先轉為 deb, 可透過 alien 這套件來完成</p><pre>// 安裝 alien 套件<br>sudo apt-get install alien</pre><pre>// rpm 轉 deb <br>sudo alien skypeforlinux-64.rpm</pre><pre>// 安裝 skype deb 檔<br>sudo dpkg -i skypeforlinux_8.53.0.85-2_amd64.deb</pre><p>最後於 skype 上即可輸入中文!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*_AbzSA8fDwK6jweJRn3YQw.png" /></figure><p>Reference</p><ul><li><a href="https://blog.longwin.com.tw/2016/07/ubuntu-linux-common-package-snap-2016/">Ubuntu 推的通用 Linux 套件格式 Snap</a></li><li><a href="https://www.rosehosting.com/blog/how-to-install-rpm-packages-on-ubuntu/">How to Install RPM Packages On Ubuntu | RoseHosting</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc29ab5a0b06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Ricky 筆記] Add Xampp icon on Ubuntu 18.04]]></title>
            <link>https://rh-tw.medium.com/ricky-%E7%AD%86%E8%A8%98-add-xampp-icon-on-ubuntu-18-04-23dbd7bbd9e7?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/23dbd7bbd9e7</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[xampp]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Tue, 05 Mar 2019 11:11:28 GMT</pubDate>
            <atom:updated>2019-10-31T05:33:47.494Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] Add Xampp icon on Ubuntu 18.04</h3><ol><li>First you need to install the package “nautilus-admin”</li></ol><pre>sudo apt-get update<br>sudo apt-get install nautilus-admin</pre><p>2. Create a new file in “/usr/share/polkit-1/actions/xampp.policy” and add this content.</p><pre>sudo nano /usr/share/polkit-1/actions/xampp.policy</pre><p>xampp.policy :</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE policyconfig PUBLIC<br> &quot;-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN&quot;<br> &quot;http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd&quot;&gt;<br>&lt;policyconfig&gt;<br><br>  &lt;action id=&quot;org.freedesktop.policykit.pkexec.run-xampp&quot;&gt;<br>    &lt;description&gt;Run the Xampp Control Panel&lt;/description&gt;<br>    &lt;message&gt;Authentication is required to run the Xampp Control Panel&lt;/message&gt;<br>    &lt;defaults&gt;<br>      &lt;allow_any&gt;no&lt;/allow_any&gt;<br>      &lt;allow_inactive&gt;no&lt;/allow_inactive&gt;<br>      &lt;allow_active&gt;auth_admin_keep&lt;/allow_active&gt;<br>    &lt;/defaults&gt;<br>    &lt;annotate key=&quot;org.freedesktop.policykit.exec.path&quot;&gt;/opt/lampp/manager-linux-x64.run&lt;/annotate&gt;<br>    &lt;annotate key=&quot;org.freedesktop.policykit.exec.allow_gui&quot;&gt;TRUE&lt;/annotate&gt;<br>  &lt;/action&gt;<br>&lt;/policyconfig&gt;</pre><p>3.To end, create a new file or edit the desktop entry on /usr/share/applications/xampp-control-panel.desktop and add this content.</p><pre>sudo nano /usr/share/applications/xampp-control-panel.desktop</pre><p>xampp-control-panel.desktop</p><pre>[Desktop Entry]<br>Encoding=UTF-8<br>Name=XAMPP Control Panel<br>Comment=Start and Stop XAMPP<br>Exec=pkexec /opt/lampp/manager-linux-x64.run<br>Icon=/opt/lampp/htdocs/favicon.ico<br>Categories=Application<br>Type=Application<br>Terminal=false</pre><p>4.Final</p><p>You can find the Xampp icon in /usr/share/application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZ2aVL497JHUgzb1o9HP2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UsNc-pOv5gaWNBIyh7Aaw.png" /></figure><p>___________________________________________________________________</p><p>補充</p><h4>nautilus</h4><p><em>在linux命令行界面中，也就是終端上，鍵入sudo nautilus，會以root權限打開一個窗口，窗口內容是終端上的位置，從而可以用root權限，對當前目錄中的文件內容進行管理，增刪改等操作。</em></p><p><em>比如有很多文件夾和文件是root用戶才能操作，所以對該文件夾或文件不能直接進行，剪貼，刪除等操作，也不能建立新文件，而用nautilus命令後就可以了。</em></p><h4>polkit-l</h4><p><em>在執行 Linux App 的時候，有時候需要用其他用戶的身份執行一些操作(通常是root用戶)，所以需要一些授權的動作。</em></p><h4>pkexec</h4><p><em>直接以root權限執行命令:比如 pkexec visudo 就可以以root身份執行 visudo 命令。</em></p><p>Reference</p><ul><li><a href="https://askubuntu.com/questions/1037792/ubuntu-18-04-xampp-desktop-icon-there-was-an-error-launching-the-application">Ubuntu 18.04 XAMPP desktop icon &quot;There was an error launching the application&quot;</a></li><li><a href="http://blog.sina.com.cn/s/blog_6640da97010155pk.html">polkit的配置_睡醒了吃饱了_新浪博客</a></li><li><a href="https://www.jianshu.com/p/aeb7f2f736a2">Linux授权弹窗：polkit</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23dbd7bbd9e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Ricky筆記] Search fd in Ubuntu]]></title>
            <link>https://rh-tw.medium.com/ricky%E7%AD%86%E8%A8%98-search-fd-in-ubuntu-bb4b14926af4?source=rss-3abc261afc12------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb4b14926af4</guid>
            <category><![CDATA[fds]]></category>
            <category><![CDATA[file-description]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[R. H.]]></dc:creator>
            <pubDate>Sat, 23 Feb 2019 02:06:23 GMT</pubDate>
            <atom:updated>2019-10-31T05:33:40.666Z</atom:updated>
            <content:encoded><![CDATA[<h3>[筆記] Search fd in Ubuntu</h3><p>Case1 : Search fd for system</p><pre>cd /dev/fd<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*BhF6SR6JrdDm56V4swrlVQ.png" /></figure><p>Case2 : Search fd by Pid</p><p>Search Pid first</p><pre>ps -aux</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XJ6aNWvtafmSYyAH6e2-QA.png" /></figure><p>Search fd by Pid (ex. Pid 8)</p><pre>ls /proc/8/fd/* -l</pre><pre>or</pre><pre>lsof -p 8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*9HeId8prX98yLm6LMsZcuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*v6FNtJL-juzEscvIXOPn5w.png" /></figure><p>Get more info about the open pipes (ex.Check Pid:[9894742])</p><pre>lsof | grep 9894742</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*-FmRHW4zj0unFTz6NDql-g.png" /></figure><p>Reference :</p><ul><li><a href="https://unix.stackexchange.com/questions/333186/how-to-list-the-open-file-descriptors-and-the-files-they-refer-to-in-my-curren">How to list the open file descriptors (and the files they refer to) in my current bash session</a></li><li><a href="https://www.cyberciti.biz/tips/linux-procfs-file-descriptors.html">Linux: Find Out How Many File Descriptors Are Being Used - nixCraft</a></li><li><a href="https://superuser.com/questions/401066/find-what-process-is-on-the-other-end-of-a-pipe">Find what process is on the other end of a pipe</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb4b14926af4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>