http://www.learn4master.com/interview-questions/system-design/system-design%E9%9D%A2%E8%AF%95 好的资料 SQL vs. NoSQL Structured Query Language Not only SQL
NoSQL redis vs memcached
redis的基本应用模式和上图memcached的基本相似,不难发现网上到处都是关于redis是否可以完全替代memcached使用的问题。
redis内部的数据结构最终也会落实到key-value对应的形式,不过从暴露给用户的数据结构来看,要比memcached丰富,除了标准的通常意义的键值对,redis还支持List,Set, Hashes,Sorted Set等数据结构。
memcached和redis都属于内存(memory)键-值(key-value)数据库,在设计和思想上有许多相同之处,功能和应用在很多场合(如分布式缓存服务)也相似。它们都从属于数据库解决方案中的nosql家族,由于两者都将数据存储在内存中,自然而然,它们都是非常理想的缓存实现方案。
Database VS file system
文件系统把数据组织成相互独立的数据文件,实现了记录内的结构性,但整体无结构;而数据库系统实现整体数据的结构化,这是数据库的主要特征之一,也是数据库系统与文件系统的本质区别。
数据库系统主要管理数据库的存储、事务以及对数据库的操作。文件系统是操作系统管理文件和存储空间的子系统,主要是分配文件所占的簇、盘块或者建立FAT、管理空间空间等
Single point of failure
A single point of failure (SPOF) is a part of a system that, if it fails, will stop the entire system from working. SPOFs are undesirable in any system with a goal of high availability or reliability. CAP theorem
Consistency
Availability
Partition tolerance
Master: the main database that you write/read data to/from.
Slave: anytime a query is executed on the
master that same query is copied down to one or more slaves and they do the exact same thing
Advantages:
If the master is down, promote one of the slaves and do some configuration. (redundacy)
If there are a lot queries, you could just load balance across database servers
For read heavy websites, any select can go to all four databases, while any insert/update/delete has to go to server master
Mastter-Master
you could write to either server one or two and if you happen to write to server1 that query gets replicated on server2 and vice versa so now you could keep it simple
Load balancing + Replication
active + active pair of load balancers
active + passive pair of load balancers, passive promote itself when receives no more packets from the active one.
and send packets to each other
Partitioning
A-M cluster and O-Z cluster
High Availability
One load balancer, two master replicating each other
Shard
一个shard里可以有多个machine。machine之间的架构有master-slave, multi masters, peer to peer(high availability)
How do we store redundant data?
Deadlock In concurrent computing, a deadlock is a state in which each member of a group is waiting for another member, including itself, to take action,
CAP theorem Partition Tolerance In the context of a database cluster, cluster continues to function even if there is a “partition” (communications break) between two nodes (both nodes are up, but can’t communicate). MongoDB https://www.jianshu.com/p/b4233105ff60
NoSQL,
RabbitMQ is a solid, general purpose message broker that supports several protocols such as AMQP, MQTT, STOMP etc. It can handle high-throughput and common use cases for it is to handle background jobs or as message broker between microservices. Kafka is a message bus optimized for high-ingress data streams and replay.
Kafka can be seen as a durable message broker where applications can process and re-process streamed data on disk. Kafka has a very simple routing approach. RabbitMQ has better option if you need to route your messages in complex ways to your consumers. Use Kafka if you need to supporting batch consumers that could be offline, or consumers that want messages at low latency.
ZooKeeper
Role of ZooKeeper. A critical dependency of ApacheKafka is Apache Zookeeper, which is a distributed configuration and synchronization service. Zookeeperserves as the coordination interface between theKafka brokers and consumers. The Kafka servers share information via a Zookeeper cluster. Zookeeper manages and coordinates the Kafka server (broker). Kafka cluster is a set of servers, each is called broker.
In computing, JavaScript Object Notation is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types
CDN is short for content delivery network. A content delivery network (CDN) is a system of distributed servers (network) that deliver pages and other Web content to a user, based on the geographic locations of the user, the origin of the webpage and the content delivery server.
This service is effective in speeding the delivery of content of websites with high traffic and websites that have global reach. The closer the CDN server is to the user geographically, the faster the content will be delivered to the user. CDNs also provide protection from large surges in traffic.
How CDNs Work
Servers nearest to the website visitor respond to the request. The content delivery network copies the pages of a website to a network of servers that are dispersed at geographically different locations, caching the contents of the page. When a user requests a webpage that is part of a content delivery network, the CDN will redirect the request from the originating site's server to a server in the CDN that is closest to the user and deliver the cached content. CDNs will also communicate with the originating server to deliver any content that has not been previously cached.
SERVER和SERVER如何COMMUNICATION
首先看看以下问题:
Node.js是什么。search engine说:Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine。
外键 foreign key:一个table受另一个table的一个key约束或者元素是另一个table的key对应元素,该key是foreign key。比如computer table 里的cpu必须从 parts table里的cpu中选择。
索引:可以对每个column items建立索引,也就是把column item排序,binary search tree,快速查找。比如:有一个table,student Id 和 student name。可以把student name建立index。这样可以快速通过student name查询student Id。SELECT peopleid FROM people WHERE name='Mike';
Description 中文 English Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequence is a list F of non-negative integers such that: 0 <= F[i] <= 2^31 - 1, (that is, each integer fits a 32-bit signed integer type); F.length >= 3; and F[i] + F[i+1] = F[i+2] for all 0 <= i < F.length - 2. Also, note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself. Return any Fibonacci-like sequence split from S, or return [] if it cannot be done. 1 <= S.length <= 200 S contains only digits. Have you met this question in a real interview? Yes Problem Correction Example Example 1: Input: "123456579" Output: [123,456,579] Example 2: Input: "11235813" Output: [1,1,2,3,5,8,13] Example 3: Input: "112358130" Output: [] Ex...
Comments
Post a Comment