三、七牛老许

qlang: github qiniu/qlang

microservice architecture: http://martinfowler.com/articles/microservices.html

Service Governance

  • Authorization
  • Logging
  • Change management
  • Central configuration
  • Scale in and scale out
  • Overload Protection
  • Service degradation
  • Monitor performance and health
  • Manage how and by whom services are used
  • Topology discovery and failure recovery

Overload Protection

  • N = Alert threshold
  • Important things
  • keep limit to N*2,not N
  • kill slow requests(SLA)

四、Dave Cheney 澳洲golang社区负责人,运行悉尼go用户组

http://dave.cheney.net/

Further reading: runtime/pprof

Further reading: Google Perf Tools

  • pprof

-memprofilerate=N adjusts the profile rate to 1/N

#visualise mem profile
go build -gcflags='-memprofile=/tmp/m.p'
go tool pprof --alloc_objects -svg $(go tool -n compile) /tmp/m.p > alloc_objects.svg
go tool pprof --inuse_objects -svg $(go tool -n compile) /tmp/m.p > alloc_objects.svg
  • benchmarking
#fib.go:
func Fib(n int) int {
if n<2 {
return n
}
return Fib(n-1)+Fib(n-2)
}
#fib_test.go:
import "testing"
func BenchmarkFib(b *testing.B) {
for n:=0;n<b.N;n++ {
Fib(20)
}
}
#go test -bench=. ./fib
    • do benchmark multiple times or use "-count=" flag
    • tools like rsc.io/benchstat are useful for comparing results
go test -bench=. -count=5 ./fib> old.txt
go test -bench=. -count=5 ./fib |tee new.txt
benchstat old.txt new.txt
benchstat {old,new}.txt
    • how fast will this bench? I think it's super fast!
package popcnt

import "testing"

const m1 = 0x5555555555
const m2 = 0x33333
const m4 = 0x0f0f0f
const h01 = 0x0101010101 func popcnt(x uint64) uint64 {
x -= (x >> 1) & m1
x = (x & m2) + ((x >> 2) & m2)
x = (x + (x >> 4)) & m4
return (x * h01) >> 56
}
func benchmarkPopcnt(b *testing.B) {
for i := 0; i < b.N; i++ {
popcnt(uint64(i)) //optimied away
}
}
#go test -bench=. ./popcnt
    • 但是被优化没有效果,要改为如下才有bench的效果
#change it to this:
var result uint64
func benchmarkPopcnt(b *testing.B) {
var r uint64
for i:=0;i<b.N;i++ {
r = popcnt(uint64(i))
}
result=r
}
    • 自己测试还是没效果,不知道为什么
  • CPU profile
go test -run=XXX -bench=IndexByte -cpuprofile=/tmp/c.p bytes
go tool pprof bytes.test /tmp/c.p
#note: -run=XXX to disable test,you only need benchmark
  • godoc
cd godoc
golang.org/x/tools/cmd/godoc
vim main.go
add one line in main--defer profile.Start().Stop()
then exec in vim:GoImports
go install -v .
godoc -http=9000
open browser and open localhost:9000
go tool pprof $(which godoc) /var/...cpu.pprof
  • enable output of GCloggin
env GODEBUG=gctrace=1 godoc -http=:8080
  • import net/http/pprof package will register a handler at /debug/pprof and default http.serveMux

it will visible if you use http.listenSndServe(adress,nil)

godoc -http:=8080,show /debug/pprof
  • some slice and string translate...

五、晚场辩论

rust-lang.org

//GO
err := f(x)
if err != nil {
retrun err;
} //Rust
try!(f(x));
f(x)?

一个关于冗长与magic的讨论

六、原射手CEO

gomobile和动态库的使用

七、米嘉

github.com/mijia/gobuildweb

github.com/mijia/web-starter-kit

@fswatch $(GO_FILES) $(TEMPLATES) | xargs -n1 -l{} make restart ||make kill
  • chubby--at the heart of google
  • go Proverbs: simple,Poetic,Pithy,no magic,composing,interface,adaptor
  • request --> onion --> response
  • basiclly we put a lot of things inside handler: like  parse request,query db,user auth, CRUD model objects, biz logic, then render the result to response xml,json etc. or panic/error.

  • go web packages:

dozens of frameworks

julienschmidt/httprouter

codegangstar/negroni

www.gorillatoolkit.org

  • go generate according to database scheme

github.com/mijia/modelg

  • go benchmark

load_test.go//测试1000000LRUcache

package demo1

import (
"fmt"
"testing"
"time"
) //TestPutPerf load tests
func TestPutPerf(t *testing.T) {
fmt.Printf("load testing on 1M size cache\n")
size := 1000000
cache := newLRUCache(size)
start := time.Now()
for i,td := range testData {
if i%10000 == 0 {
end := time.Now()
fmt.Printf("Num: %d, Used time: %v\n", i, end.Sub(start))
start = end
}
cache.Put(td.url,td.body)
}
}
go test -c
./demo1.test -test.run=Perf
//lru_cache_test.go
package demo1
import (
"fmt"
"testing"
) type testDataType struct {
url string
body string
} var testData []testDataType const testDataSize = 10000100 func init () {
testData = make([]testDataType, testDataSize)
for i:= 0; i< testDataSize; i++ {
url := fmt.Sprintf("www.fake.com/%d",i)
testData[i] = testDataType {
url: url,
body: fmt.Sprintf("This is page <b>%s</b>!",url),
}
}
} func TestBasics(t *testing.T) {
cache := newLRUCache(2)
cache.Put("1","1")
cache.Put("2","2")
res, ok := cache.Get("1")
if !ok := || res != "1" {
t.Errorf("unexpected!")
}
cache.Put("4","4")
if _, ok := cache.Get("2");ok {
t.Errorf("unexpected")
}
} //go tool pprof
func BenchmarkCacheFull1KSize(b *test.B) {
benchmarkCacheFull(b,1000)
}
func BenchmarkCacheFull1MSize(b *testing.B) {
benchmarkCacheFull(b,1000000)
}
func benchmarkCacheFull(b *testing.B, size int) {
cache := newLRUCache(size)
for i :=0;i<size;i++ {
cache.Put(testData[i].url,testData[i].body)
}
//两个Put之间有noise必须先做profiling,
//go tool pprof demo1.test prof.out -->#web
f, _ := os.Create("prof.out")
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
//先填满,之后测试每push 一个item需要多长时间
b.ResetTimer()
for i :=0; i< b.N; i++ {
c:=(i+size) % testDataSize
cache.Put(testData[c].url, testData[c].body)
}
} //demo2
//go test -v . -run XXX -bench Mill
//./demo2.test -test.run XXX -test.bench Milli -test.cpuprofile=prof.out
//go tool pprof demo2.test prof.out --> web
./demo1.test -test.run=xxx -test.bench Full
#./demo1.test -test.run=xxx -test.bench Full -test.cpuprofile=prof.out 这是不准确的,因为有很多noise,用上面方法

八、Marcel van Lohuizen -- Google Go team

golang.org/x/text 实现

  • I18n and L10n 国际化与本地化

搜索排序,大小写,双向文本,注入翻译,数字货币,日期,单位转换

  • Go uses UTF-8
const beijing="北京市"
for index,runeValue :=range beijing {
fmt.Printf("%#U 从第%d字节开始\n",runeValue,index)
}
//北从0,京从3,市从6
  • 文本的序列本质
const flags="												

golang--gopher北京大会(2)(rework)的更多相关文章

  1. golang--gopher北京大会(1)

    大会感想:牛人真的很能写代码,实现很多功能,而且开源的精品越多,影响力越大,越能过上dream life.比如beego的作者,去了America,进入了Apple.另外,精英们特点是表达能力很强,也 ...

  2. 阿里聚安全受邀参加SFDC安全大会,分享互联网业务面临问题和安全创新实践

    现今,技术引领的商业变革已无缝渗透入我们的日常生活,「技术改变生活」的开发者们被推向了创新浪潮的顶端.国内知名的开发者技术社区 SegmentFault 至今已有四年多了,自技术问答开始,他们已经发展 ...

  3. [Go] 理解 golang 中的 nil

    nil是什么 相信写过Golang的程序员对下面一段代码是非常非常熟悉的了: if err != nil { // do something.... } 当出现不等于nil的时候,说明出现某些错误了, ...

  4. Go语言的9大优势和3大缺点, GO语言最初的定位就是互联网时代的C语言, 我为什么放弃Go语言

    Go语言的9大优势和3大缺点 转用一门新语言通常是一项大决策,尤其是当你的团队成员中只有一个使用过它时.今年 Stream 团队的主要编程语言从 Python 转向了 Go.本文解释了其背后的九大原因 ...

  5. Go语言的前景分析

    本文为原创文章,转载注明出处,asdfasdfasdf 欢迎扫码关注公众号flysnow_org或者网站http://www.flysnow.org/,第一时间看后续精彩文章.觉得好的话,顺手分享到朋 ...

  6. WeX5与阿里内测的Weex与有何纠葛?快来看HTML5开发圈那些逗逼事儿!

    4月21日~23日,由infoQ主办的2016 Qcon大会北京站如期举行. HTML5开发已经成为移动开发/前端专题中无可争议的焦点,核心议题已经由前几年的是否该用HTML5转向了如何高性能.高效率 ...

  7. 2017年IT互联网圈跑会指南~

    啦啦啦~要放假啦,还有十多天就要过年啦,要走亲访友啦!相信大家也是各种胡吃海喝后,啊咧~腰上好像多了好几圈o(>﹏<)o为了让小伙伴们及时制定年后行程(减膘)计划,活动家特此奉上2017年 ...

  8. gmic全球移动互联网大会 全球九站已开启!

    由长城会主办的全球移动互联网大会( 简称GMIC)已成长为世界范围内最具影响力的辐射并连结东西半球的移动互联网商务平台,是最大规模的移动互联网行业盛会. 2017gmic全球移动互联网大会北京站将于2 ...

  9. 全球移动互联网大会gmic 2017为什么值得参加?

    长城会CEO郝义认为,"科学产业化将会推动科学复兴,"而本次GMIC 北京 2017也将首次引入了高规格科学家闭门峰会,专门设置G-Summit全球科学创新峰会,以"科学 ...

随机推荐

  1. truncate有外键约束的表,报ORA-02266处理。

    问题描述:当父表有子表的外键约束时,无法直接truncate父表.报ORA-02266: unique/primary keys in table referenced by enabled fore ...

  2. Oracle11g的delayed failed logins特性引起的性能问题

    用户反映修改密码后程序明显变慢,查看AWR发现: ASH信息如下: 进一步验证: SQL>select event,p1 from v$session t where t.username is ...

  3. Stencil Buffer

    刚在草稿箱里发现了这篇充满特色的好日志.发表之. ------------------吃货的分割线---------------------------------------- Stencil Bu ...

  4. linux -小记(2)问题:yum 安装报错"Another app is currently holding the yum lock; waiting for it to exit... ...: yum Memory : 26 M RSS (868 MB VSZ) Started: Wed Oct 26 22:48:24 2016 - 0"

    yum 安装报错 "Another app is currently holding the yum lock; waiting for it to exit... The other ap ...

  5. [solr] - spell check

    solr提供了一个spell check,又叫suggestions,可以用于查询输入的自动完成功能auto-complete. 参考文献: https://cwiki.apache.org/conf ...

  6. sql语句,怎么查看一个表中的所有约束

    sql语句,怎么查看一个表中的所有约束,比如,一个student表,有唯一,外键,主键,用sql语句怎么查看student表中的所有约束呢? select * from sysobjects wher ...

  7. [HTML] CSS 渐变

    CSS3 渐变 CSS3 渐变(gradients)可以让你在两个或多个指定的颜色之间显示平稳的过渡. 以前,你必须使用图像来实现这些效果.但是,通过使用 CSS3 渐变(gradients),你可以 ...

  8. properties文件简介及其常用Java操作

    一.properties文件简介 java中的properties文件是一种配置文件,主要用于表达配置信息,文件类型为*.properties,格式为文本文件,文件的内容是格式是"键=值&q ...

  9. 2012年第三届蓝桥杯C/C++程序设计本科B组决赛

    1.星期几(取余/excel) 2.数据压缩 3.拼音字母(比较) 4.DNA比对(dp) 5.方块填数 1.星期几[结果填空] (满分5分)    1949年的国庆节(10月1日)是星期六.     ...

  10. RealtekRTL8111内建网卡-黑苹果之路

    真是服了这神一样的黑苹果.好不容易配好显卡,登陆appstore却报“无法验证您的设备或电脑”,查了一圈,又说要配网卡为en0的,有说要在clover中配FIXLAN的,最准确的是网卡必须是内建(Bu ...