1. Background on designing io/fs The Go language’s interfaces are one of Gopher’s favorite syntactic elements. Their implicit contract satisfaction and “only currently available generic mechanism” qualities make them a powerful weapon for combinatorial-oriented programming, and their existence provides the foundation for Go to build abstractions of things, as well as being the primary means of doing so. One of the most successful interface definitions in the Go language since
Golang http.Client's connection behavior control explained
Go is known for its “self contained battery” and many developers are fond of the feature-rich standard library that comes with Go. Among the Go standard libraries, the net/http package is one of the most popular and commonly used packages, allowing us to generate a medium-performance http server with a few lines of code that supports large concurrency. http.Client is also the most widely used http client, and its performance
The "little trap" of the Go standard library flag package
The Go language is said to be “battery-included”, which means that the Go standard library is available out of the box, providing Gopher with a feature-rich set of common toolkits that are sufficient for most everyday development needs. In particular, the Go Standard Library toolkit is widely used in areas where the Go language excels. The following chart shows the results of the Official Go 2020 User Survey. We see
Use the reflect package to read and write variables of all types in the reflection world
The reflection package provided by Go in the standard library gives Go programs the ability to reflect at runtime (reflection), but this reflection ability is also a “double-edged sword”, it has the advantage of solving a specific class of problems, but also brings a lack of logic, performance problems, and difficult to find problems and debug It also brings disadvantages such as unclear logic, performance problems, and difficulty in problem
Things to know about the gRPC client
In the era of cloud-native and microservices-dominated architectural models, there are only two types of communication protocols used for internal service interactions: HTTP API (RESTful API) and RPC. With today’s hardware configurations and network conditions, modern RPC implementations generally perform better than HTTP API. We compare json over http with gRPC(insecure), using ghz and hey stress test the gRPC and json over http implementations. The performance of gRPC (Requests/sec: 59924.34)
Thanos Advanced User Guide
1. Aggregate data using Query Thanos Query can interface not only with Thanos Store Gateway, but also with any component that is compatible with Prometheus API. Here is the diagram.
Thanos Query can be interfaced with the following components.
Thanos Store Gateway Thanos Query Prometheus VictoriaMetrics Prometheus API-compatible components Using the cascading between Thanos Query, we can implement correlated queries across components to build mega-monitoring systems. This also means that each docked component should provide a fast enough Prometheus API.
Go standard library http and fasthttp server-side performance comparison
1. Background After writing the classic “hello, world” program, Go beginners may be eager to experience Go’s powerful standard library, for example, writing a fully functional web server like the following example in a few lines of code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 // 来自https://tip.g
Understanding Go escape analysis by example
Most Gophers don’t really have to care about Go variable escape analysis, or can even ignore it. But if you’re using Go in a performance-sensitive domain, where you want to completely squeeze the performance out of your Go application, then understanding Go escape analysis can be very beneficial. In this article, we’ll take a look at understanding Go escape analysis together. 1. The problem to be solved by escape analysis
Go project source code analysis with the help of functrace
The daily life of a programmer cannot be separated from “source code reading and analysis”, and the daily reading of code can only be done in these ways (or a combination of them). Combining the powerful source code cross-indexing and jumping features provided by source code editors or IDEs to establish links between codes in a large source code base. running the code up, adding some print output to the
A global images distribution network
1. Global network planning Many globally oriented multi-regional infrastructures are designed without much thought put into network planning at the beginning. When the complexity of the business reaches a certain level, they are then forced to make network adjustments and optimizations. And any major adjustments on the network will have a huge impact on the business. In the end, you will be caught in a dilemma and have to invest more manpower, carry the historical burden, and walk on the precipice again and again.
A brief comparison of mainstream Kafka clients in the Go community
I. Background As we all know, Kafka is a star open source project under the Apache Open Source Foundation. As an open source distributed event streaming platform, it is used by thousands of companies for high-performance data pipelines, stream analysis, data integration, and mission-critical applications. In China, large and small companies, whether they deploy their own or use Kafka cloud services like those provided by AliCloud, many Internet applications are
Process creation in Linux
Regardless of the field, building is often much more difficult than destroying. Building a building may take years, while destroying it may be a matter of seconds. At the root of this, because construction is an entropy-reducing process, there must be an input of energy from outside the system. One type of problem in creation that seems even more special is the problem of origins. How did the first life
Clickhouse deployment and use in cloud-native scenarios
ClickHouse is a column-oriented database management system (DBMS) for online analytical processing (OLAP) of queries. Clickhouse Features A true column-oriented DBMS In a true column-oriented DBMS, no additional data is stored along with the values. Beyond that, this means that constant length values must be supported to avoid storing their length “numbers” next to the values. For example, a billion UInt8 type values should consume about 1 GB uncompressed, otherwise
Understanding Go Execution Tracer by Example
Netflix’s performance architect Brendan Gregg in his book “BPF Performance Tools” gives a detailed description of tracing, sampling, and other concepts are described in detail to help developers understand these concepts and classify performance optimization aids based on these concepts and clarify their applicability. Some of them are cited here as follows. Sampling tools use a subset of measurements to paint a rough picture of the target; this is also
Using go-metrics to add metrics to Go applications
The Go language has a built-in expvar, and we can customize various metrics based on the support for basic metrics provided by expvar. But expvar only provides the lowest level of metric definition support, for some complex metric scenarios, third-party or self-implemented metrics packages are essential.
The go-metrics package is the most used metrics package in the Go domain, and it is an incomplete Go port of Coda Hale’s Metrics library, which is still very active in the Java community (I have to sigh: the Java ecosystem is really powerful).
How to use the uber open source zap log library very well
Logging has an important place in the back-end system. Not only can logs visualize the current running state of the program, but more importantly they can provide clues to developers when something goes wrong with the program. In the Go ecosystem, logrus is probably the most used Go logging library, which not only provides structured logs, but more importantly is compatible with the standard library log package at the api
Figuring out the Golang plugin
To count the features in Go that I haven’t used yet, the go plugin introduced in Go 1.8 is one of them. Recently I wanted to design a plugin system for a gateway-type platform, so I thought of the go plugin ^_^. Go plugin supports compiling Go packages to be distributed separately as shared libraries (.so), and the main application can dynamically load these go plugins compiled as dynamic shared
Go I/O multiplexing based TCP protocol stream parsing in practice
In the article “Go Classical Blocking TCP Stream Parsing in Practice”, we implemented a custom TCP stream-based parsing protocol based on Go’s classical blocking I/O model. The advantage of this one-connection-per-goroutine model is that it is simple, well-written, and well-understood, reducing the mental burden on developers. However, once the number of connections is up, the number of goroutines increases linearly. When faced with a large number of connections, this model
Go classical blocking TCP protocol stream parsing in practice
1. Go’s TCP network programming model for classical blocking I/O The Go language has made rapid development over the past decade or so since its birth and has been widely accepted and used by developers around the world for a wide range of applications, including: Web services, databases, network programming, system programming, DevOps, security detection and control, data science, and artificial intelligence. The following are some of the results of
Fix the contents of the Error.cshtml file of the ASP.NET MVC 5 project template in Visual Studio
The /Views/Shared/Error.cshtml view (View) file for the ASP.NET MVC 5 project templates from Visual Studio 2017 all the way to Visual Studio 2022 is wrong. When I was teaching the ASP.NET MVC 5 course, I had to Google the full example of this file or look for a version I had written before. Today’s article explains the problem and provides a complete example program for me to quickly find the