Big Data Foundation: Google GFS

Introduction to the GFS system Google File System (abbreviated as GFS or GoogleFS), a proprietary distributed file system developed by Google Inc. It differs from traditional file systems in that it is. Distributed - provides a high degree of horizontal scalability Networked using a large number of inexpensive common machines - allows for single machine failure No Random Write - does not allow arbitrary changes to existing files Google did not release the software part of the system as open source software.

Understanding the Embedding Features of the go Language

The Go language has no classes, so there is no inheritance, so you can only combine various functions by embedding features (for convenience, we will call them embedding). The simplest is the interface embedding interface, for example, we have defined Reader and Writer interfaces. 1 2 3 4 5 6 7 type Reader interface { Read(p []byte) (n int, err error) } type Writer interface { Write(p []byte) (n int,

Go is a better PHP

Many php programmers switch to go because of the current environment. Today I bring you a new perspective - “go is a better php”. It starts with the article PHP showing its maturity in release 7.4. The article says that PHP is maturing from version 7.4 and lists the following advantages of PHP. Complete object-oriented programming support, mainly including namespace to handle naming conflicts interface separates implementation from interface traits code mixin support type system restricts the types of function parameters, return values, and class members A comprehensive dependency management system, which is mainly implemented by composer.

Introduction to DNS SVCB/HTTPS records

The IETF is introducing a new type of record for DNS called SVCB/HTTPS. this SVCB/HTTPS record can solve some very important problems and I have been following the advancement of the standard. Today I’ll give you an introduction. 1987 CNAME records The DNS system first supported CNAME records in 1987 (RFC 1034), which means canonical name in Chinese. For example, we can set the a.example.com record type to CNAME and its value to b.

Analysis of efficiency issues of TCP-based VPNs

I have recently been working on the implementation of the AnyConnect protocol and service, an enterprise virtual private network (VPN) system developed by Cisco, and one of its core selling points is the UDP-based DTLS channel. In this article, we’ll analyze why UDP is used to transport VPN data. VPNs work at the network layer, and all that is transmitted over the VPN tunnel is IP packets, which are unreliable. To achieve reliable transmission, we need to use TCP protocol.

About iptables release port invalid issue

I recently wanted to run a VPN service on my router and needed to open the port to the outside world. After adding the rule, it didn’t work. After searching the Internet, it turns out that the problem is caused by the priority of iptbles rules. Today to give you an analysis. Suppose we want to open port 80 of tcp to the public, we can add rules like this.

Linux LAN transfer of large files

Today I need to copy a large file (about 20G) to my router’s hard drive. Usually people think of using the scp command. scp is short for ssh copy. I tried it and the speed is only 5M or so. It took almost an hour to finish copying, which was unbearable. So I looked into how to speed up the transfer speed. So why is it slow? The main reason is that ssh encrypts 🔐 the communication content, the sender has to encrypt and the receiver has to decrypt.

Concurrency safety for Go language maps

It is well known that Go’s map is not a concurrency-safe data structure. If more than one goroutine reads and writes the same map, an error is reported. I’m ashamed to say that I always thought this error could be caught with recover. Until yesterday, a colleague raised this question and sent me a demo code. Today, I took the time to study the knowledge, organize it and share it with you.

Go language implementation of text to image

I recently needed to convert a large section of text into a picture. After checking the web, I found the project hqbobo/text2pic and found that it adds a box to each character when rendering the Song-like font. So I simply researched how to render text in Go. Finally developed the txtimg widget. Today I’ll share the relevant experience in summary. The body of the code is taken from the official

Go 1.18 will introduce a new network address packet

A long time ago, I came across an article by Brad Fitzpatrick called netaddr.IP: a new IP address type for Go. Brad is the core developer of the Go language and founder of tailscale, and in this article he analyzes the problems with the Go language net.IP type and their solution to them and how it evolved. Eventually Brad and his team open sourced the inet.af/netaddr package. I took a

Go HTTP Service Timeout Control

The system must control the timeout time of each link when providing HTTP services to the outside world, otherwise it is vulnerable to DDos attacks. The business framework used by our department is based on the Go language net/http standard library secondary development. When I was developing the framework, I did not have a deep understanding of the timeout control of the Go HTTP server. TimeoutHandler in the outermost layer

Copy text using vim across ssh

Recently, a friend asked how to copy the contents of vim on the server to the local clipboard without using the mouse. To be honest, I always select and copy directly with the mouse. But since my friend asked, I had to do some research. I really found a solution that doesn’t use the mouse. This method can not only copy the contents of vim to the local clipboard, but also to the local tmux clipboard, very convenient.

Rob opposes changes to the Go 1.18 generic standard library

Rob Pike, the father of the Go language, previously created issue to oppose the introduction of generic support in the standard library in Go 1.18. Rob’s move was both unexpected and justified. Rob’s rationale was twofold: the scope of the change was too large, and the lack of real-world experience. So Rob suggested not to change the standard library in Go 1.18, but to provide a generic version of the

Vim Macro Quick Start

Vim provides a macro recording feature that allows you to record a series of actions and then repeat them. This feature is relatively cold, but also very powerful. Just because the operation is complicated, few people learn and rarely use. But I think the idea of macros is very simple, the reason why I think it is complex is not particularly good real-world cases to reflect its value. I came across a more suitable scenario for the use of macros when I was modifying the Sniper framework today.

Use systemd to listen to the service port

The http service of the website is developed in Go. Because it listens to the standard ports 80 and 443, the http service is always run under the root account. But running with root is very risky. If the code is vulnerable and the bad guys break it, they will get root access and the consequences will be unthinkable. That’s why http services like nginx support setting the account under which the worker processes run.

Develop website message function based on IMAP mailbox

The site has been online for a few months now and there has been no message function. A friend suggested adding a message or discussion support. My earliest thought was that leaving a message is a very low frequency operation, and I also left my email address on my personal page. If a friend really needs to discuss a problem, he or she can send an email. But the actual

Developing a simple Vim search plugin

Recently, I was going to write a vim introductory article for new Go developers, so I started to organize my vim configuration and plug-in system. While sorting out the file-related plugins, I found myself using the ack plugin. ack itself has no file search capability; it uses tools like ack/ag to search for articles. The plugin itself only serves the purpose of calling commands and displaying results. Since it is relatively simple, why not implement one yourself?

Using JWT for user authentication in Golang

Doing user authentication with JWT is a relatively simple way. Common authentication methods The mainstream methods of user authentication are broadly classified as session-based and token-based. User authentication with JWT sesion-based authentication method User sends username and password to the server. The server authenticates and saves relevant data in the current conversation (sesion), such as user role, login time, etc. The server returns a session_id to the user, which is

Kubernetes mounted subpath containers fail to mount when restarting after configmap changes

Kubernetes has a problem with mounted subpath containers that continue to crash after configmap or other volume changes if the container quits unexpectedly and does not start properly. Kubernetes has now released version 1.18 and this issue still exists. Community-related issue #68211 Reproduction steps 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 --- apiVersion: v1 kind: Pod metadata: name: test-pod spec: volumes: - configMap: name: extra-cfg name: extra-cfg containers: - name: test image: ubuntu:bionic command: ["sleep", "30"] resources: requests: cpu: 100m volumeMounts: - name: extra-cfg mountPath: /etc/extra.

Pod targeted migration support in Kubernetes

Native K8s does not support migration of a given Pod from the current node to another given node. However, we can implement support for this feature based on the extension capabilities provided by K8s. Background In K8s, kube-scheduler is responsible for scheduling the Pods that need to be scheduled to a suitable node. It computes the best node to run the current Pod through various algorithms. When a new Pod