By Yunlei
Contributed by Alibaba Cloud Storage
Presto is an open-source distributed SQL query engine by Facebook, which is suitable for interactive queries and analysis. You can use Presto to query data from gigabytes to petabytes. The architecture of Presto evolved from the RDS architecture. Presto stands out among various memory computing databases because of the following aspects:
This article introduces Presto from the outside to the inside.
Presto uses a typical master-slave model:
In the worker's configuration, the configuration could be:
1. The ip:port of discovery
2. An http address contains the service inventory, including the discovery address.
{ "environment": "production", "services": [ { "id": "ffffffff-ffff-ffff-ffff-ffffffffffff", "type": "discovery", "location": "/ffffffff-ffff-ffff-ffff-ffffffffffff", "pool": "general", "state": "RUNNING", "properties": { "http": "http://192.168.1.1:8080" } } ] }
3. A local file address with the same content as principle 2
The principles of 2 and 3 are based on service inventory. The worker will dynamically monitor this file. If there is any change, load the latest configuration and point to the latest discovery node.
In design, both discovery and coordinator are a single node. If multiple coordinators survive at the same time, the worker will randomly report the process and task status to one of them, resulting in split-brain. There may be deadlocks when a query is scheduled.
Discovery and Coordinator Availability Design: Due to the use of the service inventory, the monitoring program can modify the content in the service inventory and point to the discovery of the standby machine after the discovery is hung, thus seamlessly doing the switching. The configuration of a coordinator must be specified when the process starts, and multiple coordinators cannot survive in the same cluster. The best way is to configure it to the same machine with discovery. The secondary machine deploys standby discovery and coordinator. Normally, a secondary machine is a cluster that only contains one machine. When the primary machine is down, the heartbeat of the worker is instantly switched to secondary.
Presto adopts a three-layer table structure:
The Presto storage unit includes:
Different types of blocks:
1. The Array block type is applied to a type of fixed width, such as int, long, and double.
Block consists of two parts:
2. A variable-width block is applied to string data and consists of three parts of information:
3. A string block with a fixed width. The data of all rows is concatenated into a long string of Slice. The length of each row is fixed.
4. Dictionary Block: The distinct value is small for some columns, which is suitable for saving with a dictionary. There are two main parts:
After getting a hold of the data model of Presto, you can write plug-ins for Presto to connect to your storage system. Presto provides a set of connector interfaces to read metadata from custom storage and column storage data. First, look at the basic concepts of connector:
Plug-ins can help developers add these features:
Presto provides a simple connector (local file connector) that can be referred to as how to implement the connector. However, the unit of traversal data used in the local file connector is cursor, which is a row of data rather than a page. Hive implements three types of connectors: parquet, orc, and rc file.
This article introduces some principles of Presto from a macro perspective. The next article of the series will go deeper into Presto to help readers understand some internal designs, which will be of great use for performance tuning and the addition of custom operators.
Disclaimer: The views expressed herein are for reference only and don't necessarily represent the official views of Alibaba Cloud.
An In-Depth Understanding of Presto (2): Presto Memory Management
1,081 posts | 271 followers
FollowAlibaba Cloud Community - February 8, 2023
Alibaba Cloud Community - February 10, 2023
Apache Flink Community China - September 27, 2020
降云 - January 12, 2021
Alibaba EMR - April 2, 2021
vboylin - May 10, 2019
1,081 posts | 271 followers
FollowPlan and optimize your storage budget with flexible storage services
Learn MoreA cost-effective, efficient and easy-to-manage hybrid cloud storage solution.
Learn MoreProvides scalable, distributed, and high-performance block storage and object storage services in a software-defined manner.
Learn MoreBuild a Data Lake with Alibaba Cloud Object Storage Service (OSS) with 99.9999999999% (12 9s) availability, 99.995% SLA, and high scalability
Learn MoreMore Posts by Alibaba Cloud Community