西维蜀黍

【Network】端口转发(Port Forward)

Forward A Local Port to A Local/External Port

ssh

Refer to https://swsmile.info/post/linux-ssh-usage/

socat

Refer to https://swsmile.info/post/linux-socat/

iptables

Refer to https://swsmile.info/post/linux-iptables/

  ...


【FreeBSD】pfctl

PF (Packet Filter)

PF (Packet Filter, also written pf) is a BSD licensed stateful packet filter, a central piece of software for firewalling. It is comparable to netfilter (iptables), ipfw, and ipfilter.

PF was developed for OpenBSD, but has been ported to many other operating systems.

Usages

Show

# shows how it has interpreted the filtering rules in your config file, including substitutions and defaults
$ pfctl -s

# Shows the NAT rules
sudo pfctl -s nat (or pfctl -sn): 

# Shows all the things
sudo pfctl -s all (or pfctl -sa): 
  ...


【Database】Column-oriented DBMS(列式数据库管理系统)

Background

A relational database management system provides data that represents a two-dimensional table of columns and rows. For example, a database might have this table:

RowId EmpId Lastname Firstname Salary
001 10 Smith Joe 60000
002 12 Jones Mary 80000
003 11 Johnson Cathy 94000
004 22 Jones Bob 55000

This simple table includes an employee identifier (EmpId), name fields (Lastname and Firstname) and a salary (Salary). This two-dimensional format is an abstraction. In an actual implementation, storage hardware requires the data to be serialized into one form or another.

The most expensive operations involving hard disks are seeks. In order to improve overall performance, related data should be stored in a fashion to minimize the number of seeks. This is known as locality of reference, and the basic concept appears in a number of different contexts. Hard disks are organized into a series of blocks of a fixed size, typically enough to store several rows of the table. By organizing the table’s data so rows fit within these blocks, and grouping related rows onto sequential blocks, the number of blocks that need to be read or sought is minimized in many cases, along with the number of seeks.

A survey by Pinnecke et al.[1] covers techniques for column-/row hybridization as of 2017.

  ...


【Architecture】System Design - Budget/Quota System

Background

  • Operators of a E-commerce platform wanna control the budget allocated to a specified promotion.
    • E.g, for big sellers (especially), they would like to set a special Shipping Fee rule/promotion (cap, time period, etc) for certain days like Super Brand Day, or local Super Brand Day. And during those big events, a budget cap is involved.
  • So as to
    • Increase the adoption of promotions created by sellers, which may save the E-commerce’s platform’s costs
    • Provide an finer granularity to control promotions, in terms of especially costs
    • …
  ...


【Architecture】System Design - Transaction Storage

  ...


【Blockchain】Blockchain(区块链)

Blockchain

A blockchain is a distributed ledger with growing lists of records (blocks) that are securely linked together via cryptographic hashes.Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a Merkle tree, where data nodes are represented by leaves). Since each block contains information about the previous block, they effectively form a chain (compare linked list data structure), with each additional block linking to the ones before it. Consequently, blockchain transactions are irreversible in that, once they are recorded, the data in any given block cannot be altered retroactively without altering all subsequent blocks.

Blockchains are typically managed by a peer-to-peer (P2P) computer network for use as a public distributed ledger, where nodes collectively adhere to a consensus algorithm protocol to add and validate new transaction blocks. Although blockchain records are not unalterable, since blockchain forks are possible, blockchains may be considered secure by design and exemplify a distributed computing system with high Byzantine fault tolerance.

  ...


【Distributed System】分布式系统的数据一致性 - Paxos

  ...


【Distributed System】分布式系统的数据一致性 - Quorum

  ...


【Distributed System】分布式系统的数据一致性 - Raft

  ...


【MySQL】Lock Demo(锁实验)- Delete

Principle

For locking reads (SELECT with FOR UPDATE or FOR SHARE), UPDATE, and DELETE statements, the locks that are taken depend on whether the statement uses a unique index with a unique search condition or a range-type search condition.

  • For a unique index with a unique search condition, InnoDB locks only the index record found, not the gap before it.
  • For other search conditions, and for non-unique indexes, InnoDB locks the index range scanned, using gap locks or next-key locks to block insertions by other sessions into the gaps covered by the range.

In other words, DELETE FROM ... WHERE ... sets an exclusive next-key lock on every record the search encounters. However, only an index record lock is required for statements that lock rows using a unique index to search for a unique row.

  ...