An Introduction To Web Service

tangliu@kingsoft.com

Agenda



  • Introduction
  • An Example
  • Some Solution

Introduction


What's web service?


A web service is a software function provided at a network address over the web or the cloud (from wiki)

Some Example?


How to do?


  • HTTP
  • API
  • Data Protocol

HTTP


No HTTP, No web.
All are based on HTTP!


  • HTTP Request
  • HTTP Response

API



  • RPC
    http://host/bucket/addFile?name=abc
    http://host/bucket/getFile?name=abc
  • Restful
    post http://host/bucket/abc
    get http://host/bucket/abc

Data Protocol


  • XML
  • JSON
  • etc......

Basic for HA Service


  • Availability
  • Scalability
  • Reliability
  • Manageability
  • etc......

CAP


  1. Consistency
  2. Availability
  3. Partition Tolerance

Example

File Storage Web Service



Two Method:

  • upload
  • download

Initial Architecture




FS Service: store file

Client: upload or download file from FS Service directly


I think it's like a FTP.

But when files are too many?

Partition




File: Meta + Data
Data are stored in difference Data Service
Meta Service can find where


How to find?

How to find?


Generality: Hash

  • Simple Hash: id(file name) % number(Data Service)
  • Consistent Hash

Consistent Hash

Consistent Hash

Control and Data Flow


Many Clients download file data through meta service?

  1. Client request Meta Service to download
  2. Meta Service return Data Service location
  3. Client download from Data Service directly

Redundancy


Data Storage may corrupted!!!


Backup, when master failed, use backup service!

Cache


Can download more quickly?


  • Cache Expired?
  • Cache Consistent?

Load Balancer


Meta Service may also have bottleneck!

Proxy


Use proxy for safer download!!!

GFS


Some Solution

Service HA



Heartbeat

Keepalived

MYSQL HA


  • Master/Slave
  • Master/Master
  • Semi-Sync Replication
  • etc...

OceanBase


Any Question?

Thank You!!!