西维蜀黍

【Architectural Pattern】三层架构(Three-tier Architecture)

Three-tier Architecture

Three-tier architecture is a well-established software application architecture that organizes applications into three logical and physical computing tiers: the presentation tier, or user interface; the application tier, where data is processed; and the data tier, where the data associated with the application is stored and managed.

The chief benefit of three-tier architecture is that because each tier runs on its own infrastructure, each tier can be developed simultaneously by a separate development team, and can be updated or scaled as needed without impacting the other tiers.

  ...


【Domain】领域驱动设计(Domain Driven Design)

Domain-driven design (DDD)

Domain-driven design (DDD) is the concept that the structure and language of software code (class names, class methods, class variables) should match the business domain. So that the designed system is high conhesion and low coupling

For example, if a software processes loan applications, it might have classes such as LoanApplication and Customer, and methods such as AcceptOffer and Withdraw.

  ...


【TrueNAS】Rsync 同步

My Case

# via SMB
$ time rsync -aPXcv --delete test-rsync /Volumes/SSDPool2/rsync
# via ssh
$ time rsync -avPX --delete -e 'ssh -p 34270' ../myBlogV2 root@192.168.18.93:/mnt/SSDPool2/DS/rsync

# via rsync protocol
$ rsync -aPXz --delete myBlogV2 rsync://192.168.18.93/sw_rsync/
# sync from ubuntu to truenas
$ rsync -az -vvvv node_exporter-1.0.1.linux-amd64.tar.gz rsync://192.168.18.93/sw_rsync/

  ...


【macOS】Too Many Open Files

System Level

By default, the maximum number of files that Mac OS X can open is set to 12,288 and the maximum number of files a given process can open is 10,240.

You can check these with:

$ sysctl kern.maxfiles
$ sysctl kern.maxfilesperproc

You can increase the limits (at your own risk) with:

$ sysctl -w kern.maxfiles=20480
$ sysctl -w kern.maxfilesperproc=18000

To make the change permanent, use sudo to put your settings in /etc/sysctl.conf (which you may have to create), like this:

kern.maxfiles=20480
kern.maxfilesperproc=18000

Note: In OS X 10.10 or lower, you can add setting in /etc/launchd.conf like limit maxfiles and it will override whatever you put here.

  ...


【FreeBSD】Too Many Open Files

System Level

$ sysctl -a |grep files
kern.maxfiles: 780418
kern.maxfilesperproc: 702369
kern.openfiles: 627
p1003_1b.mapped_files: 200112
  ...


【Linux】命令 - ulimit

Demo

# Get the properties of all the user limits:
$ ulimit -a 

# Get hard limit for the number of simultaneously opened files:
$ ulimit -H -n

# Get soft limit for the number of simultaneously opened files:
$ ulimit -S -n

# Set max per-user process limit:
$ ulimit -u 30
  ...


【Linux】Too Many Open Files

System Level - FD Limits

file-max is the maximum file descriptors (FD) enforced on a kernel level, which cannot be surpassed by all processes.

Use the following command command to display maximum number of open file descriptors:

$ cat /proc/sys/fs/file-max
9223372036854775807
# or
$ sysctl fs.file-max
fs.file-max = 9223372036854775807

9223372036854775807 files normal user can have open in single login session.

To change the general value for the system /proc/sys/fs/file-max, change the fs.file-max value in /etc/sysctl.conf:

$ fs.file-max = 100000

And apply it:

$ sysctl -p

  ...


【Linux】命令 - rsync

Install

macOS

$ brew install rsync

Ubuntu

$ sudo apt-get install rsync

Configuration of the rsync Daemon

The rsync daemon is an alternative to SSH for remote backups. Although more difficult to configure, it does provide some benefits. For example, using SSH to make a remote backup of an entire system requires that the SSH daemon allow root login, which is considered a security risk. Using the rsync daemon allows for root login via SSH to be disabled.

Edit the file /etc/default/rsync to start rsync as daemon using xinetd. The entry listed below, should be changed from false to inetd.

RSYNC_ENABLE=inetd

Install xinetd because it’s not installed by default.

$ sudo apt-get -y install xinetd

Create the file /etc/xinetd.d/rsync to launch rsync via xinetd. It should contain the following lines of text.

service rsync
{
    disable = no
    socket_type = stream
    wait = no
    user = root
    server = /usr/bin/rsync
    server_args = --daemon
    log_on_failure += USERID
    flags = IPv6
}

Create the file /etc/rsyncd.conf configuration for rsync in daemon mode. The file should contain the following. In the file, user should be replaced with the name of user on the remote machine being logged into.

max connections = 2
log file = /var/log/rsync.log
timeout = 300

[share]
comment = Public Share
path = /home/share
read only = no
list = yes
uid = nobody
gid = nogroup
auth users = user
  ...


【Engineering】Coupling

Coupling

In software engineering, coupling is the degree of interdependence between software modules; a measure of how closely connected two routines or modules are;[1] the strength of the relationships between modules.

Coupling and cohesion Coupling is usually contrasted with cohesion. Low coupling often correlates with high cohesion, and vice versa. Low coupling is often thought to be a sign of a well-structured computer system and a good design, and when combined with high cohesion, supports the general goals of high readability and maintainability.

  ...


【Linux】命令 - su

To confirm that the user is changed, use the whoami command:

$ whoami
# Switch to superuser (requires the root password):
$ su

# Switch to a given user (requires the user's password):
$ su username

# Switch to a given user and simulate a full login shell:
$ su - username

# Execute a command as another user:
$ su - username -c "command"
  ...