-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] HighLoadCup Go

, 18 2017 . 14:43 +
WebProd 14:43

HighLoadCup Go

HighLoadCup Mail.ru (- ). .


: User, Location, Visit. REST-API , .. 6 .

  • {GET, POST} /user/:id
  • {GET, POST} /location/:id
  • {GET, POST} /visit/:id
  • POST /user/new
  • POST /location/new
  • POST /visit/new

, , HTTP- .


++, . Go . , . , , net/http, encoding/json , .


200 , JSON- . http- ( ) fasthttp, JSON buger/jsonparser ( , ), , - .

type User struct {
	id  uint
	email string
	first_name  string
	last_name string
	gender bool
	birth_date int64

	age   int
	visits Visits
	json []byte
}

type Location struct {
	id uint
	place string
	country string
	city string
	distance int64

	visits Visits
	json []byte
}

type Visit struct {
	id uint
	location *Location
	user *User
	visited_at int64
	mark int64

	json []byte
}

, . , 10- ( ).


. FAQ, - . , .

:

func countAge(timestamp *int64) int {
	now := time.Now()
	t := time.Unix(*timestamp, 0)

	years := now.Year() - t.Year()
	if now.Month() > t.Month() || now.Month() == t.Month() && now.Day() >= t.Day() {
		years += 1
	}

	return years
}


10 2 RPS. . JSON , , , . , , . , ( 10 ).

, . fasthttp tcp- epoll. 65 , .


39 , . , Go highload ( highload). , - ( ), 28 .

( , ) . (busy-polling, ). , , .

P.S. :)

( - ) .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/338156/

:  

: [1] []
 

:
: 

: ( )

:

  URL