Professional Documents
Culture Documents
On The Exam We Can Have 1 Cheat Sheet: Blg/Edit?Usp Sharing
On The Exam We Can Have 1 Cheat Sheet: Blg/Edit?Usp Sharing
INTRODUCTION
1) What is a distributed database system?
A distributed database (DDB) is a collection of multiple, logically interrelated databases
distributed over a computer network.
1
3) What is the meaning of the transparency in distributed database systems.
Transparency is the separation of the higher level semantics of a system from the lower
level implementation issues.
Lower level implementation:
The data is distributed in a network - location
The data is replicated
The data is fragmented
High level:
The DB is used like a normal DB the user is not concerned about the implementation
level
4) Describe the most important issues (problems) that are handled by a distributed
database system.
How to distribute the database - replication ? fragmentation?
How to optimize query? the problem is NP-hard
Concurrency control- many users many systems, access synchronization, consistency &
isolation of transactions
Reliability- how to make the system resilient to failures - Atomicity and durability of
transactions
2
+
7) Present the database server and the distributed database server architectures.
3
Introduction to no-SQL database systems
1) What were the main motives for the design of the novel database systems?
to decrease complexity
Horizontal scalability and running on comodity hardware -> hight throughput
Decrease cost of setting up a database cluster
Cloud computing
2) What are the main design considerations in modern database management systems?
Main memory -> ram DB
Multi thread and resource control
high availability -> shared nothing
Remove bottleneck of redo-log and undo-log
3) List the main directions used for the design of H-Base (Stonebraker) database
system.
4
DISTRIBUTED DATABASE DESIGN
Database distribution design
1) Describe the concepts of a fragment and the fragmentation of the relational
distributed database.
Fragment: we fragment subsets of relations
-> because transactions access only different portions of relations rarely the whole
relation
-> increase the level of concurrency
-> views defined over multiple fragments suffer performance degradation
-> hard to perform semantic data control, like integrity checking, because relations are
split and attributes are decomposed on different fragments on different sites
2) Explain the concept of a degree of fragmentation.
The degree of fragmentation goes from one extreme, that is, not to fragment at all
(relations), to the other extreme, to fragment to the level of individual tuples (in the case
of horizontal fragmentation) or to the level of individual attributes (in the case of vertical
fragmentation)
-> We need to find a suitable level of fragmentation that is a compromise between the
two.
-> How to find it? we have to understand the application needs!!!
3) Describe the allocation alternatives for the given fragmentation of the database.
•Non-replicated ➡ partitioned : each fragment resides at only one site
•Replicated ➡ fully replicated : each fragment at each site
➡ partially replicated : each fragment at some of the sites
RULE OF THUMB - read query / update query << 1
replication is advantageous
otherwise replication may cause problems
5
4) What information requirements does the process of the distributed database design
have?
MANY FACTORS CONTRIBUTE TO THE OPTIMAL DESIGN!!!
->Database information - logical organization
➡ Application information
➡ Communication network information
➡ Computer system information
5) Describe the problem of the primary horizontal fragmentation.
HORIZONTAL FRAGMENTATION:
It refers to the division of a relation into subsets (fragments) of tuples (rows). Each
fragment is stored at a different node, and each fragment has unique rows. However,
the unique rows all have the same attributes (columns).
The data of a relation (table) is split between nodes on a criteria defined like a value.
example: data about product -> split between nodes by price
price <200 on node A price >= 200 on node B
Primary horizontal fragmentation of a relation is performed using predicates that are
defined on that relation
PROBLEM:
Completeness of a predicate -> a predicate is complete if an only if there is an equal
probability of access by every application to any tuple or fragment defined according to
the predicate -> we get a balanced load!!
A predicate is minimal iff it causes a fragment f to be further fragmented into, say, fi
and fj), there should be at least one application that accesses fi and fj differently.
MINTERM: combination of more predicates
6) Present the algorithm COM_MIN for finding a complete and minimal set of simple
predicates.
This algorithm, called COM MIN, an iterative algorithm that would generate a complete
and minimal set of predicates Pr0 given a set of simple predicates Pr.
Given: a relation R and a set of simple predicates Pr
Output: a complete and minimal set of simple predicates Pr' for Pr
7) Describe the algorithm PHORIZONTAL for computing the set of minterm predicates
from the set of simple predicates.
6
Makes use of COM_MIN to perform fragmentation.
Input: a relation R and a set of simple predicates Pr
Output: a set of minterm predicates M according to which relation R is to be fragmented
Pr' COM_MIN (R,Pr)
determine the set M of minterm predicates
determine the set I of implications among pi Pr
eliminate the contradictory minterms from M
8) Explain derived horizontal fragmentation.
Relations: PAY & EMPLOYEE
Owner: Pay
Member: Employee
-> pay 1 - N Employee
-> We can split Employee by pay!!
A derived horizontal fragmentation is defined on a member relation (pay) of a link
according to a selection operation specified on its owner (Employee). It is important to
remember two points. First, the link between the owner and the member relations is
defined as an equi-join. Second, an equi-join can be implemented by means of semijoins.
This second point is especially important for our purposes, since we want to partition a
member relation according to the fragmentation of its owner, but we also want the
resulting fragment to be defined only on the attributes of the member relation.
9) What are the information requirements for the vertical fragmentation?
VERTICAL FRAGMENTATION:
It refers to the division of a relation into attribute (column) subsets. Each subset
(fragment) is stored at a different node, and each fragment has unique
columns—with the exception of the key column, which is common to all fragments.
INFORMATION REQUIREMENTS:
The major information required for vertical fragmentation is related to applications
7
related the attributes are. Unfortunately, it is not realistic to expect the designer or
the users to be able to easily specify these values
10) Describe the role of the clustering algorithm employed for vertical fragmentation.
It is designed specifically to determine groups of similar items as opposed to, say, a
linear ordering of the items (i.e., it clusters the attributes with larger affinity values
together, and the ones with smaller values together)
HOW TO MEASURE AFFINITY???
affinity (Ai , Aj ) = SUM( (number of query access) all queries that access Ai and Aj)
ACCESS FREQUENCY MATRIX:
rows : query
Columns: nodes (sites)
cell: number of execution of that query Qi on site Sj
AFFINITY MATRIX:
rows: Atributes Ai
Cols: Atributes Aj
cell: number of execution of a query that accessed Ai and Aj at the same time
CLUSTERING ALGORITHM:
Take the attribute affinity matrix AA and reorganize the attribute orders to form clusters
where the attributes in each cluster demonstrate high affinity to one another
11) Give a general description of the clustering algorithm Bond-Energy.
BEA finds an ordering of entities (in our case attributes) such that the global affinity
measure is maximized
Out clustered affinity matrix -> atributes with high affinity are near
12) Explain the cluster forming algorithm for vertical fragmentation.
in: Clustered affinity matrix
result:
8
How can you divide a set of clustered attributes {A1 , A2 , …, An} into two (or more) sets
{A1 , A2 , …, Ai} and {Ai , …, An} such that there are no (or minimal) applications that
access both (or more than one) of the sets.
13) Describe the information requirements for the database allocation.
Database Information
➡ selectivity of fragments
➡ size of a fragment
•Application Information
➡ number of read accesses of a query to a fragment
➡ number of update accesses of query to a fragment
➡ A matrix indicating which queries updates which fragments
➡ A similar matrix for retrievals
➡ originating site of each query
•Site Information
➡ unit cost of storing data at a site
➡ unit cost of processing at a site
•Network Information
➡ communication cost/frame between two sites
➡ frame size
14) Describe the allocation model for assigning fragments to servers.
We are searching for the minimum total cost:response time constraint
storage constraint processing constraint
Response time: execution time of a query
Query processing cost: acces cost + integrity enforcement cost + concurrency control
acces cost = SUM_allSites(SUM_allFragments(updates + read access))
Storage constraint: storage requirements of a fragment on the site -> for all fragments
Processing constraints : processing load on a site
•Attempts to reduce the solution space
➡ assume all candidate partitionings known; select the “best” partitioning
➡ ignore replication at first
➡ sliding window on fragments
9
DISTRIBUTED QUERY
PROCESSING
Introduction
10
➡ Reorder operations to reduce intermediate relation size
➡ Optimize individual operations
OPTIMIZATION WHEN?
Static -> recieve query -> optimize -> execute
Dynamic -> recieve query -> optimize in runtime
11
Query decomposition is the first phase of query processing that transforms a relational
calculus query into a relational algebra query.
Both input and output queries refer to global relations, without knowledge of the distribution
of data. -> Therefore, query decomposition is the same for centralized and distributed
systems.
Process of the distributed query decomposition:
Normalization: Lexical and syntactic analysis + Transform query in conjunctive normal form
(p1 V p2 V p3) ∧ ( ….) ∧ ( …. )
Analysis: Reject type incorrect or semantic incorrect query
Simplification: eliminate redundancy -> redundant predicates
Restructuring: Rewrites the relational calculus in relational algebra
Problem: more than one transformation can exist ! Some are faster than others!!
2) Present the query graph and the join graph together with their function.
A query is semantically incorrect if its query graph is not connected! It shows the whole
query. -> in picture a query graph is connected -> The query is sematically correct!
The join graph is particularly useful in the query optimization phase.
12
Projection = SELECT in SQL
Selection = WHERE in SQL
13
Group subsequent projections: σ1 p1(σ2 p2 (R)) = σ p1∧p2 R
Query optimization
14
The idea is to find the best global schedule - minimize a cost function = I/O cost + CPU cost
+ communication cost
Query first goes into search space generation which provides an QEP (Query Execution
Plan), then it provides search strategy, test the search strategy with the cost model
Iteratively repeat to find the best QEP.
Chose the part qi that produces the smallest result and build the linear tree.
Determine the processing site
15
Determine fragments to move
Repeate
execution plan:
q3 -> q2 -> q4 ->q1 equivalent to Q
Dynamically generate all the best permutations of the query. Exhaustive search
For every candidate query evaluate the cost functio.
First find the best access method to each individual relation by using selection.
Second for each relation R find the best JOIN ordering -> based also on indexes
-> Choose the best execution plan that minimizes the cost function
For joins take into account NESTED LOOP (inner relation indexed or small) and MERGE
JOIN (good if relations are sorted)
7) Explain the concept of the join ordering as used in distributed query optimization.
Where should we make the JOIN??
The Data is distributed / fragmented ! -> At which node should we JOIN?
By data size!!
if size(node1) < size(node2) move the data from node1 to node2 and join in node2!!
HOW? JOIN: L ⋈ R L=outer R=inner (depends on JOIN
implementation loop, merge and indexes)
1. SHIP WHOLE: outer to the inner site -> outer rows can be joined as they arrive (if
merge join)
2. SHIP WHOLE: inner to the outer site -> inner rows can’t be joined as they arrive, so
we need to store them in an TMP relation.
3. FETCH-AS-NEEDED: for each row in outer FETCH a row in inner site and join as it
arrives. (good if inner is small and indexed. works as semijoin)
4. MOVE BOTH to a THIRD SITE: firts inner aand save it in TMP then outer and
compute JOIN as the outer arrive
WHAT IS SEMIJOIN?
Returns all the records from the left side that have matches from the right. The
result table contains columns from the left side only
16
DISTRIBUTED TRANSACTION
MANAGEMENT
Transactions
17
4) Give a bird's-eye view of the transaction processing. What components and software
modules are involved?
**?????**??*??
Ne bo uprašal!
TM: Transaction manager- manages the transaction states also defines the distributed
transaction execution model and has replica control
SC:Scheduler - distributed concurrency control over READ and WRITE
RM:Recovery manager in local
Concurrency control
1) Present the concepts of a schedule, history, serial and serializable history, and global
serializability.
The problem of synchronizing concurrent transactions such that the consistency of the
database is maintained while, at the same time, maximum degree of concurrency is
achieved.
Problems: Lost updates- The effects of some transactions are not reflected on the database
Inconsistent retrievals- reads inconsistent data :C
18
Schedule or history:An order in which the operations of a set of transactions are executed
a partial order over the operations of a set of transactions
Serializable history: transactions run concurrently, but the result is equivalent to serial
history (zaporedno izvajanje)
19
ONLY ONE CENTRALIZED SCHEDULER!!! -> one central LM (lock manager)
TM (transaction manager) at each site is sending lock request to central LM and gets back
lock granted to TM and then TM allow to execute operation on the site!!
Deadlocks
2) Present the wait-for graph and its use in distributed database systems.
Wait-for graph is a directed graph used for deadlock detection in database systems. If
there is no cycle in a directed graph there is no deadlock present. If there is one however,
20
we are stuck in a circular wait. In that case, transaction manager aborts some of the
transactions to free up resources.
Source:
http://www.mathcs.emory.edu/~cheung/Courses/554/Syllabus/8-recv+serial/deadlock-waitfor
.html
knjiga:
Deadlock cannot occur in any case!
The TM permits the execution of a transaction only if all the recources needed by the
transaction are availbable.
Resource must be reserved, but not necessary allocated apriori.
Evaluation:
● reduced concurrency due to preallocation
● load overhead to calculate if an allocation is safe
● difficulty to determine
● no need for transaction rollback
Deadlock avoidance -> handles deadlocks before they occur. It analyzes the
transactions and the locks to determine whether or not waiting leads to a deadlock.
Deadlock detection and removal -> r uns a deadlock detection algorithm periodically and
removes deadlock in case there is one. It does not check for deadlock when a
transaction places a request for a lock. When a transaction requests a lock, the lock
manager checks whether it is available. If it is available, the transaction is allowed to lock
the data item; otherwise the transaction is allowed to wait.
Source:
21
https://www.tutorialspoint.com/distributed_dbms/distributed_dbms_deadlock_handling.htm
The method can be briefly stated as follows. Transactions start executing and request data
items that they need to lock. The lock manager checks whether the lock is available. If it is
available, the lock manager allocates the data item and the transaction acquires the lock.
However, if the item is locked by some other transaction in incompatible mode, the lock
manager runs an algorithm to test whether keeping the transaction in waiting state will
cause a deadlock or not. Accordingly, the algorithm decides whether the transaction can
wait or one of the transactions should be aborted.
There are two algorithms for this purpose, namely wait-die and wound-wait. Let us assume
that there are two transactions, T1 and T2, where T1 tries to lock a data item which is
already locked by T2. The algorithms are as follows −
● Wait-Die − If T1 is older than T2, T1 is allowed to wait. Otherwise, if T1 is younger than
T2, T1 is aborted and later restarted.
● Wound-Wait − If T1 is older than T2, T2 is aborted and later restarted. Otherwise, if T1 is
younger than T2, T1 is allowed to wait.
Source:
https://www.tutorialspoint.com/distributed_dbms/distributed_dbms_deadlock_handling.htm
6) Present the deadlock detection and recovery methods (centralized, distributed, and
hierarchical).
The deadlock detection and removal approach runs a deadlock detection algorithm
periodically and removes deadlock in case there is one. It does not check for deadlock
when a transaction places a request for a lock. When a transaction requests a lock, the
lock manager checks whether it is available. If it is available, the transaction is allowed
to lock the data item; otherwise the transaction is allowed to wait.
22
Since there are no precautions while granting lock requests, some of the transactions
may be deadlocked. To detect deadlocks, the lock manager periodically checks if the
wait-forgraph has cycles. If the system is deadlocked, the lock manager chooses a
victim transaction from each cycle. The victim is aborted and rolled back; and then
restarted later. Some of the methods used for victim selection are −
● Choose the youngest transaction.
● Choose the transaction with fewest data items.
● Choose the transaction that has performed least number of updates.
● Choose the transaction having least restart overhead.
● Choose the transaction which is common to two or more cycles.
This approach is primarily suited for systems having transactions low and where fast
response to lock requests is needed.
Source:
https://www.tutorialspoint.com/distributed_dbms/distributed_dbms_deadlock_handling.h
tm
Centralized deadlock detection:
One central site is the deadlock detector
Every site sends periodically WFG to the central site
The central site merge all WFG to a global WFG to determine cycles.
Distributed deadlock detection:
Each site has a local WFG which is passed to other sites.
If a cycle occur in a local WFG the deadlock can be handled locally
If a cycle occur in a merged WFG it indicates a potential global deadlock -> pass info to
other sites in the cycle and solve the deadlock
Hierarchical:
Similar to distributed, but deadlock are not solved globally but hierarchically
23
DATA REPLICATION
Replication
2) Why do we replicate?
We replicate to increase system availability. By doing that we avoid single points of failure.
With replication we increase performance and scalability (in numbers and geographic area)
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Replication.pdf
page 2
Knjiga:
24
1SR states that the effect of transactions on replicated data items should be the same as if
they had been performed one at a time on a single set of data items. (celotna zgodovina
update na replication je isti, kot da se bi zgodil zaporedno )
6) Describe eager centralized protocols (limited and full transparency) for replication.
Limited Transparency: -> user application knows who is MASTER
Applications submit update transactions directly to the master.
Master then reads locally and returns the data to the user. Writing gets executed locally on
master and then replicated to slaves.
Read to slaves is ossible, but the slave must obtain read lock on MASTER, to confirm that
the data is consistent!!
differences:
Master doesn’t deal with reads but it just confirm locks
Master doesn’t propagate write ! -> this is the job of the coordinator that takes the request
Source:
25
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Replication.pdf
page 17
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Replication.pdf
page 25
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Replication.pdf
page 27
26
PARALLEL DATABASE SYSTEMS
Parallel database systems
1) Explain the I/O bottleneck problem in database systems and its solution.
An I/O bottleneck is a problem where a system does not have fast enough
input/output performance. I/O bottlenecks can be caused by various things and
require various solutions.
Solution is to increase I/O bandwidth, by data partitioning or in other words parallel
data access.
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 2
2) Describe the data server architecture. What are the benefits and drawbacks?
Separation of concerns:
Application server + Data server
Benefits:
- Integrated data control by the server (black box)
- increased performance by dedicated systems
- can better exploit parallelism
- fits well in distributed environments
Drawbacks:
27
- Communication overhead between application and data server
- high cost of mainframe servers
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 6
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 9
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 11
28
5) Explain the linear speed-up and linear scale-up.
Linear speed-up:
Linear increase in performance for a constant DB size and proportional increase of the
system components (processor, memory, disk)
Constant DB -> performance increase if we add more components
Linear scale-up:
Sustained performance for a linear increase of database size and proportional increase of
the system components.
DB increase -> performance stays the same if we add more components
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 11
29
Session manager: transaction monitor providing support for client interactions. Perform the
connection and disconnection of client and maintain a user session for executing
transactions.
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 15
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 16
30
This is what has come to be known as an SMP (symmetric multiprocessor). Memory
and peripherals are shared among many processors. The advantages are easy
programming and load balancing. The problem is low fault isolation because of the
shared memory.
problems:
high cost
conflict acces the shared memory if we have many processors
Limited extensibility of processors
Source:
https://www.sciencedirect.com/topics/computer-science/parallel-database
Problem: global cache consistency !!!! -> need to use 2PL and distributed locking
Source:
https://www.sciencedirect.com/topics/computer-science/parallel-database
Source:
https://www.sciencedirect.com/topics/computer-science/parallel-database
31
11) Present the NUMA (CC-NUMA) architecture of a parallel DBMS.
Main memory is distributed so that every processor has its own memory but all the
processors can access all other processors memories. Since different processors
can access the same data, cache consistency protocols are needed.
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 27
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 28
13) Describe the data partitioning methods and the forms of parallel query execution for
each method.
Data partition: how to split data to nodes
Each relation is divided in n partitions(subrelations), where n is a function of relation size
and access frequency
Round-robin:
Maps i-th element to node i mod n.
Simple but only exact match queries are possible.
32
B-tree index:
Supports range queries but large index
Data is split in intervals
Hash function:
Split data by hash function
Supports only exact-match queries but small index.
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
page 31
Intra-query parallelism:
It is the form of parallelism where Single Query is executed in parallel on many
processors.
Inter-operation parallelism:
the process of speeding up a query through parallelizing the execution of individual
operations. The operations which can be parallelized are Sort, Join, Projection,
Selection and so on.
Intra-operation parallelism:
One operator is decomposed in a set of indipendent sub-operators that can be
executed in parallel
the process of speeding up a query through parallelizing various operations which
are part of the query. For example, a query which involves join of 4 tables can be
executed in parallel in two processors in such a way that each processor shall join
two relations locally and the result1 and result2 can be joined further to produce the
final result.
Source:
http://www.exploredatabase.com/2014/03/interquery-and-intraquery-parallelism.html
15) Describe three main algorithms for parallel evaluation of the join operator.
- Parallel nested loop join: no special assumption
R join S:
each fragment of R is sent and replicated at each node containing a fragment of S.
Each node containing a fragment of S recieves the whole relation R and joins Whole R with
local S.
33
Then the union of all joins is computed
Whole operation:
- Parallel associative join: one relation is declustered on join attribute and equi-join
- Parallel hash join: same as parallel associative join but with indexes on R and S
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
Page 43
Algorithm:
hash(R.A) and send tuples to the correct node
(receive only usefull data ) Perform the join locally at each S node
Compute the union of the results
34
In the first phase, relation R is sent associatively to the S-nodes based on the hash function
h applied to attribute A. In the second phase, each Sj-node receives in parallel from the
different R-nodes the relevant subset of R (i.e., Rj ) and joins it locally with the fragments Sj.
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/Parallel-DBMS.pdf
Page 49
17) Describe the search space, the search strategy, and the cost model of a distributed
query optimizer.
Search space:
Is the space of a problem domain where search problems are conducted. Execution
plans are abstracted by means of operator trees.
Search strategy:
A search strategy is an organised structure of key terms used to search a database. The
search strategy combines the key concepts of your search question in order to retrieve
accurate results. It functions as a heuristic based optimization.
Source:
https://en.wikipedia.org/wiki/Search_algorithm
https://library.leeds.ac.uk/info/1404/literature_searching/14/literature_searching_explai
ned/4
https://dev.mysql.com/doc/refman/5.7/en/cost-model.html
35
NOSQL DBMS: CONCEPTS,
TECHNIQUES AND PATTERNS
1) Present the main characteristics of the BASE consistency model?
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/NoSQL-Concepts.pdf
page 4
CAP theorem -> you can have only two of them in a shared-data system
Source:
http://osebje.famnit.upr.si/~savnik/predmeti/IPPB/NoSQL-Concepts.pdf
page 5
36
Lamport has definied a local logical ordering where the order is defined by a logical
relation A(x) -> B(x+1) = A happened before B
All nodes have a local clock (lamport timestamp) at the beginning is 0
A node increments its counter for each event: execution of an operation, message sent,
message recieved
When a node sends a message, it includes its incremented counter value with the
message
on the recieving of a message its counter is updated to the max(local clock,recieved
clock) +1
Ordering of events is determined by transitivity: A->B and B->C then A->C
we get only a partial ordering: not every two events can be comparable
If two events are not comparable, then this events are concurrent they happened at the
same time and are (neodvisni)
But you can’t determine if two events are concurrent or it’s an error.
37
OCC assumes that multiple transactions can frequently complete without interfering with each
other.
While running, transactions use data resources without acquiring locks on those resources.
Before committing, each transaction verifies that no other transaction has modified the data it has
read. If the check reveals conflicting modifications, the committing transaction rolls back and can
be restarted
7) Describe the use of memory caches (e.g., Memcached system) for distributed NoSQL
systems.
MEMCACHED:
light-weight key/value interface where all key-valuetuples are stored and served from
DRAM
Interface -ADD/SET add a key/value object from the disk to the RAM
- GET(key) retrieve the value
- DELETE delete a key/value object
uses HASH table to index key/value pairs
key/values are stored in pages subdivided into chunks
-> replicate most frequent request in the main memory
38
8) Explain the database cluster architecture of distributed database systems.
High availability
Partition the data in such way that the data typically requested and updated together resides
on the same node
-> horizonta partitioning of the whole data store not only tables!
each shard may have the same schema but different data
WHY sharding??
Lookup sharding:
we have a logic that maps virtual shards to physical partitions
Range sharding:
Grouping data by a value in the same node ! -> like group by month
good for range query
problems one month produces more data than others
Hash sharding:
Partition data by a hash function
good for load balancing
bad for range query
39
10) Describe the consistent hashing approach to partitioning in a distributed database
system.
Consistenc hashing:
we want to cache web pages with URL x at the cache server h(x) mod n
How to search?
h(x)=x0 go to position x0 and move to right find s2 and search for the value in s2.
What if we want to add a server? h(s)=value and move only objects on the left of value to the
new server
How to split data more evenly between nodes? -> make everything virtual! -> virtual copies
of server in the hash range that maps data to the physical server
Split each node in more virtual values well separated in hash range
40