Go concurrency control, anti breakdown - singleflight
background
In high concurrency scenarios, there are often concurrent accesses to the same resource. These concurrent request parameters are the same, and the response results are the same. If each request repeatedly queries the resource, it will undoubtedly bring unnecessary overhead to the system and increase the system pressure.
In order t ...
Added by system_critical on Thu, 24 Feb 2022 16:51:56 +0200
[Golang] gRPC service discovery and load balancing based on ETCD
Three modes of load balancing: https://grpc.io/blog/grpc-load-balancing/
ProxyThick client(Client side)Lookaside Load Balancing (Client side)
Basic usage
server side registration service
Register the service information to the kv center when the service starts
import(
...
"go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client ...
Added by stearnol on Thu, 24 Feb 2022 12:54:58 +0200
Practical solution to obtain mp4 format file information, duration, etc. and exploration of mp4 storage structure
1, Know mp4
The format of MP4 file is mainly defined by MPEG-4 Part 12 and MPEG-4 Part 14. Among them, MPEG-4 Part 12 defines the ISO basic media file format to store time-based media content. MPEG-4 Part 14 actually defines the MP4 file format, which is extended on the basis of MPEG-4 Part 12.
Composition of MP4
MP4 file is composed of ...
Added by sunnypal on Wed, 23 Feb 2022 14:20:26 +0200
pprof actual combat - memory leak
scene
Multiple services are running in one server. After running for a period of time (less than one day), it is found that a process occupies more than 50% of memory resources, resulting in server exceptions
Solution
First, start pprof performance analysis in the code
runtime.SetBlockProfileRate(1)
go func() {
log.Println(http.ListenAnd ...
Added by shaoen01 on Wed, 23 Feb 2022 10:21:02 +0200
Go admin framework analysis log system
Code address, logger branch: https://gitee.com/lsjWeiYi/go-admin/tree/logger/
Go admin's log system looks very detailed. It really records every process of the whole process, and it runs through the whole framework. It encapsulates a lot of modules. It is strongly coupled with the log system. advantage:
Rich logs are very helpful for the oper ...
Added by johnny on Wed, 23 Feb 2022 04:53:41 +0200
python to go learning notes -- functions
function
//Basic grammar
func Function name (parameter list ) (Return value list) {
Function body
}
The naming rules of functions follow the identifier naming standard. Functions with uppercase letters can be used by this package file and other files, similar to public; Files with lowercase initials can only be used by this package, whic ...
Added by yanjchan on Wed, 23 Feb 2022 04:31:22 +0200
Learning notes from python to go -- common functions
String function
The common system functions and built-in functions in string are not very different from those in python, and their names are also very similar
**Len function: * * returns the length of the string. Unlike python's len() function, golang is utf-8 encoded, so Chinese characters will become three lengths.
func main() {
str : ...
Added by lansing on Wed, 23 Feb 2022 04:20:02 +0200
[golang] leetcode intermediate - Change Exchange & longest rising subsequence
Question 1 ChangesubjectGreedy (invalid)In daily life, if we want to exchange change, the most simple thinking is naturallyIf a coin with a larger denomination can be used, it is preferredThis is the thinking of greedy algorithmcodefunc coinChange(coins []int, amount int) int {
var res int
sort.Ints(coins)
if amount==0{return 0}
...
Added by unreal128 on Tue, 22 Feb 2022 14:20:05 +0200
Using wego framework to realize user login function
introduce
This paper illustrates how to use wego framework to realize user login function through a simple example. The main functions are as follows:
When a user accesses a page requiring login authentication, he will first check the login account of the session. If there is no login account, he will jump to the login page.After the user sub ...
Added by CanMan2004 on Mon, 21 Feb 2022 05:04:16 +0200
Go Quiz: precautions for function naming and return value from the go interview question (more than 80% of people answered wrong)
subjectChief engineer of Redhat and Maintainer of Prometheus open source project Bartłomiej Płotka A Go programming question was asked on Twitter, and more than 80% of the people answered it wrong.The title is as follows. Answer the output of the following program.// named_return.go
package main
import "fmt"
func aaa() (done func(), err error ...
Added by wmac on Sun, 20 Feb 2022 08:21:42 +0200