西维蜀黍

【Linux】设置程序开机启动

修改开机启动文件 - /etc/rc.local

  • 或者/etc/rc.d/rc.local

  • 修改rc.local文件,在 exit 0 前面加入以下命令

    # mysql开机启动
    /etc/init.d/mysqld start                                         
    /bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
    
  • 最后修改rc.local文件的执行权限

    [root@localhost ~]# chmod +x  /etc/rc.local
    [root@localhost ~]# chmod 755 /etc/rc.local
    
  ...


【Ubuntu】Install Kvm

  ...


【Performance】性能测试(Performance Testing)

Software Performance Testing

In software quality assurance, performance testing is in general a testing practice performed to determine how a system performs in terms of responsiveness and stability under a particular workload. It can also serve to investigate, measure, validate or verify other quality attributes of the system, such as scalability, reliability and resource usage.

Performance testing, a subset of performance engineering, is a computer science practice which strives to build performance standards into the implementation, design and architecture of a system.

  ...


【Performance】性能

Computer Performance

In computing, computer performance is the amount of useful work accomplished by a computer system. Outside of specific contexts, computer performance is estimated in terms of accuracy, efficiency and speed of executing computer program instructions. When it comes to high computer performance, one or more of the following factors might be involved:

  • Short response time for a given piece of work.
  • High throughput (rate of processing work).
  • Low utilization of computing resource(s).
  • Fast (or highly compact) data compression and decompression.
  • High availability of the computing system or application.
  • High bandwidth.
  • Short data transmission time.
  ...


【Network】localhost

Localhost

In computer networking, localhost is a hostname that refers to the current computer used to access it. It is used to access the network services that are running on the host via the loopback network interface. Using the loopback interface bypasses any local network interface hardware.

Question

I have seen 127.0.0.1 is local host address. But what is it and what is the differences between this and my local adapter like LAN IP address or WLAN IP address. Is there any connection between this l27.0.0.1 and my LAN or WLAN Network card?

  ...


【Golang】Dependency Injection in Golang

Without frameworks

Dependency injection is passing a dependency to another object or structure. We do this as it allows the creation of dependencies outside the dependant object. This is useful as we can decouple dependency creation from the object being created. Lets look at an example of dependency injection in Go:

type DataStore interface {}

type PersonResource struct {
	Store DataStore
}

func New(store DataStore) *PersonResource {
	return &PersonResource{Store: store}
}
  ...


【Engineering】Testing

  ...


【Engineering】依赖注入(Dependency Injection)

依赖注入 (Dependency Injection)

In software engineering, dependency injection is a technique in which an object receives other objects that it depends on, called dependencies.

Typically, the receiving object is called a client and the passed-in (‘injected’) object is called a service.

The code that passes the service to the client is called the injector. Instead of the client specifying which service it will use, the injector tells the client what service to use. The ‘injection’ refers to the passing of a dependency (a service) into the client that uses it.

  ...


【Design Pattern】Microservices - Distributed Tracing Pattern

Context

You have applied the Microservice architecture pattern. Requests often span multiple services. Each service handles a request by performing one or more operations, e.g. database queries, publishes messages, etc.

Problem

How to understand the behavior of an application and troubleshoot problems?

  ...


【Data Format】Data Serialization/Encoding Format

Background

Old and new versions of the code, and old and new data formats, may potentially all coexist in the system at the same time. In order for the system to continue running smoothly, we need to maintain compatibility in both directions:

  • Backward compatibility: Newer code can read data that was written by older code.
  • Forward compatibility: Older code can read data that was written by newer code.

Backward compatibility is normally not hard to achieve: as author of the newer code, you know the format of data written by older code, and so you can explicitly handle it (if necessary by simply keeping the old code to read the old data). Forward compatibility can be trickier, because it requires older code to ignore additions made by a newer version of the code.

Formats for Encoding Data

Programs usually work with data in (at least) two different representations:

  1. In memory, data is kept in objects, structs, lists, arrays, hash tables, trees, and so on. These data structures are optimized for efficient access and manipulation by the CPU (typically using pointers).

  2. When you want to write data to a file or send it over the network, you have to encode it as some kind of self-contained sequence of bytes (for example, a JSON document). Since a pointer wouldn’t make sense to any other process, this sequence-of-bytes representation looks quite different from the data structures that are normally used in memory.

Language-Specific Formats

Many programming languages come with built-in support for encoding in-memory objects into byte sequences. For example, Java has java.io.Serializable [1], Ruby has Marshal [2], Python has pickle [3], and so on. Many third-party libraries also exist, such as Kryo for Java [4].

These encoding libraries are very convenient, because they allow in-memory objects to be saved and restored with minimal additional code. However, they also have a number of deep problems:

  1. The encoding is often tied to a particular programming language, and reading the data in another language is very difficult. If you store or transmit data in such an encoding, you are committing yourself to your current programming language for potentially a very long time, and precluding integrating your systems with those of other organizations (which may use different languages).
  2. In order to restore data in the same object types, the decoding process needs to be able to instantiate arbitrary classes. This is frequently a source of security problems [5]: if an attacker can get your application to decode an arbitrary byte sequence, they can instantiate arbitrary classes, which in turn often allows them to do terrible things such as remotely executing arbitrary code
  3. Versioning data is often an afterthought in these libraries: as they are intended for quick and easy encoding of data, they often neglect the inconvenient problems of forward and backward compatibility.
  4. Efficiency (CPU time taken to encode or decode, and the size of the encoded structure) is also often an afterthought. For example, Java’s built-in serialization is notorious for its bad performance and bloated encoding

For these reasons it’s generally a bad idea to use your language’s built-in encoding for anything other than very transient purposes.

  ...