Berkeley DB 的介紹

在滿滿都是 NoSQL 的世代中,意外在「Berkeley DB: Architecture」這邊看到 Berkeley DB 的介紹...

2006 年 Berkeley DB 的公司 SleepycatOracle 收購。在收購後 Oracle 改變了 open source 授權部份,從之前的 Sleepycat License 改成了 AGPLv3

Berkeley DB 算是早期功能很完整的 database library,由於 page level locking、crash-safe 加上有 transaction,也曾經被 MySQL 拿去當作 engine,不過在 MySQL 5.1 被拔掉:「14.5 The BDB (BerkeleyDB) Storage Engine」。

文章裡講了很多底層設計上的想法 (而非單純只說明「做了什麼」),以四個面向來討論。Buffer、Lock、Log 以及 Transaction,並且圍繞著 ACID 需求討論。

算是懷念的考古文?Google 弄出來的 LevelDBFacebook 接著改善的 RocksDB 的走向也不太一樣了,現在大家對 ACID 需求因為 NoSQL 盛行的關係又重新在檢視...

為了解決 HiNet 到 CloudFlare 機房品質不好而做的掙扎...

前幾天在「TVBS 的 CloudFlare 客製化...」這邊提到這件事情,當天就先隨手測了一些東西。

首先是 CloudFlare 的服務 IP 是互通的,也就是說,我就算拿其他人的 CNAME mapping 來用,只要有送出對應的 Host: 或是 SNI (for HTTPS) 就會通,而 TVBS 當時的 IP address (以及網段) 對於台灣 HiNet 使用者剛好會導到美國機房,還算可以用。

另外 CloudFlare 有提供列表 (文字格式,一行一個網段),分別是 IPv4 的 https://www.cloudflare.com/ips-v4 以及 IPv6 的 https://www.cloudflare.com/ips-v6

所以就有幾種組合了,一種是寫 Google Chrome 的 extension 直接改 IP address,不過看了看 JavaScript APIs - Google Chrome 想不出來怎麼寫。

另外一個是先用 iptables 把這些網段的流量導去美國的 CloudFlare 機房。結果這時候發現 HiNet 到 TVBS 已經改回到香港機房了 orz

實際抓了一下發現 188.114.97.100 在巴西機房 (GRU 是 IATA 代碼),就變成只是測試看看這有沒有用了:

$ curl -x http://188.114.97.100:80/ http://s.plurk.com/cdn-cgi/trace
fl=42f16
h=s.plurk.com
ip=114.32.152.63
ts=1441004146.723
visit_scheme=http
uag=curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
colo=GRU
spdy=off

由於是自己機器出去的封包,不能用 PREROUTING 做,要用 OUTPUT 做:

iptables -t nat -A OUTPUT -d 190.93.240.0/20 -j DNAT --to-destination 188.114.97.100

然後再直接連到 s.plurk.com 就可以看到:

$ curl http://s.plurk.com/cdn-cgi/trace
fl=42f16
h=s.plurk.com
ip=114.32.152.63
ts=1441004011.195
visit_scheme=http
uag=curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
colo=GRU
spdy=off

不過巴西也太遠了點,而且不知道哪天這段 IP 又會被 anycast 進去... orz

Google Chrome 與 Firefox 上擋廣告軟體的效能比較

在「10 Ad Blocking Extensions Tested for Best Performance」這篇看到各個 Ad Blocker 軟體的比較。

對各網站測試了載入速度、記憶體使用量、CPU 使用率,重點應該是最後的圖:

其中最知名的 AdBlock Plus (ABP) 會最慢的原因也很簡單,因為他預設值會放行廣告,這導致了效能掉很多:

If you’re wondering why the popular AdBlock Plus got low scores in some Chrome tests, the answer is simple and it’s purely down to the acceptable ads check box. Disable “Allow some non-intrusive advertising” and AdBlock Plus will performance wise, sit in the middle of the pack.

在 ABP 把 acceptable ads 擋掉後速度就比較接近了。不過,如果你願意接受 acceptable ads,也不應該選擇 ABP,因為其他也有支援 acceptable ads 的軟體效能比較好:

Whatever your opinion on acceptable ads, using the option in ABP is not recommended and if you wish to support showing specific ads while browsing, use something else. AdBlock, Adguard, AdRemover and SuperBlock all have an acceptable ads option of some sort, but none suffer a performance drop like ABP.

最後的結論,不論是 Google Chrome 或是 Firefox,贏家都是 uBlock Origin

The overall winner in Firefox is simply the quickest, and that was µBlock origin. µ AdBlock is a fair choice if you want an easy to use but fast blocker, the rest are almost identical so it’s down to personal preference and the options available as to which one you use.

The winner in Chrome is a closer call when you consider the results from all three tests. But as it got a couple of firsts and a second, we would say µBlock Origin is the definite winner, it truly is fast and efficient as the author claims. Both Ghostery and Adguard are still excellent choices and are viable alternatives to µBlock Origin providing good performance in all 3 categories.

Ghostery 雖然也會因為少讀很多東西進來而加快速度,不過拿來一起比好像怪怪的...

網路廣告愈來愈誇張,阻擋的功能變成趨勢了,在桌機上支援的軟體愈來愈完善,而在行動裝置上,iOS 9 也開始支援了:「Content blocking in iOS 9 is going to screw up way more than just ads」。

Cisco 開發新的 Video Codec:Thor

Cisco 開發新的 Video Codec 與 HEVC (H.265) 競爭,專案名稱叫做 Thor:「World, Meet Thor – a Project to Hammer Out a Royalty Free Video Codec」。

沒什麼意外,專利問題是主要的原因:

Unfortunately, the patent licensing situation for H.265 has recently taken a turn for the worse. Two distinct patent licensing pools have formed so far, and many license holders are not represented in either. There is just one license pool for H.264. The total costs to license H.265 from these two pools is up to sixteen times more expensive than H.264, per unit. H.264 had an upper bound on yearly licensing costs, whereas H.265 has no such upper limit.

不過一開頭寫到 VP9 是 proprietary 的描述讓人很不解:

There are two of note – Google’s proprietary VP9 codec, and the industry standard H.265 (HEVC) codec, which is the successor to H.264 (AVC).

往下拉 comment 看果然就有人提出來:

How exactly is VP9 more "proprietary" than Thor? Both are open sourced under BSD license, both are royalty free, both are intended to be unencumbered by patents. Are you defining "proprietary" as "not controlled by Cisco"?

不知道在搞什麼鬼...

HTTPS 的進展

Tony Hunt 在「We’re struggling to get traction with SSL because it’s still a “premium service”」這篇文章裡抱怨了目前 web 要朝向 HTTPS only 還很遠,甚至還酸了一下 Let's Encrypt 冨樫問題:

可是東尼... 你的站也沒上 HTTPS 啊 :/

順便整理一下目前 HTTPS 技術發展出來的優點:

現在網站的 best practice 是 HTTPS + HTTP/2,對 SEO 好、速度又快 (這兩個對營收有影響),而另外也可以增加安全性 (對聲譽有幫助)。

uBlock₀ 提供阻擋 WebRTC 取得 Local IP address 的功能

Google Chrome 上之前是透過 WebRTC Block 之類的軟體阻擋網站透過 WebRTC 取得 Local IP address 的功能,現在則內建在 uBlock₀ 內了。

在「You can block WebRTC from leaking your IP now in uBlock Origin」這邊看起來是這個月月初 (2015 年 7 月) 開發出來的功能。

WebRTC Leaktest 交叉測試可以發現 Public IP address 的部份,目前測過的套件都擋不下來,但 Private IP address 的部份都有順利擋下來。

又可以少裝一個套件了...

更新 Twitter Expand Preview Image 樣式...

在「預設展開 Twitter 圖片的 Userstyle」這邊利用 CSS 效果展開圖片,這次更新把多張圖片的縮圖也展開了:「Twitter Expand Preview Image」。

連帶的,本來有裝「Photo Zoom for Twitter」就順便移除了...

這次學到 unset 這個屬性:「unset - CSS | MDN」,現在 Google Chrome 也才 43,也就是在 Google Chrome 上是兩個版本前的 41 才支援的...

預設展開 Twitter 圖片的 Userstyle

Twitter 上遇到比較大張的圖片要自己展開,之前在 Google Chrome 上面是用 Previeweet 解決,但這個套件已經年久失修...

研究了 Twitter 的 CSS 結構,看起來可以用 Stylish 處理掉,就寫了一個 style 上傳上去:「Twitter Expand Preview Image」。

這樣看圖片方便多了...

Google Cloud Platform 也推出了類似 Spot Instance 的產品

Google Cloud Platform 推出了類似於 Amazon EC2 的 Spot Instance 的產品,叫做 Preemptible VM:「Introducing Preemptible VMs, a new class of compute available at 70% off standard pricing」。

不同的是,沒有引入競價系統,而是固定的 discount。另外有一些限制,像是最多持續 24 小時:

The tradeoff is that Preemptible VMs are limited to a 24 hour runtime, and will sometimes be preempted (shut down) earlier than that.

而停機通知時間比 Spot Instance 短,只有 30 秒 (相較於 Spot Instance 有兩分鐘):

When Preemptible VMs are terminated, they'll receive a 30 second notice allowing you to shutdown cleanly (including saving work, if applicable).