Slide 1

Slide 1 text

Python bindings to GlusterFS - a distributed filesystem Open Space @ PyCon India 2016 September 24-25, New Delhi Prashanth Pai Software Engineer, Red Hat

Slide 2

Slide 2 text

➔ Open source ➔ Distributed and scale out ➔ Highly available (failover) ➔ Single global namespace ➔ Commodity hardware ➔ Massively scalable GlusterFS

Slide 3

Slide 3 text

➔ GlusterFS Native Client (FUSE) ➔ NFS ➔ SMB/CIFS ➔ Object (Swift and S3 APIs over HTTP) ➔ libgfapi library Data Access Methods

Slide 4

Slide 4 text

Node 1 FUSE NFS SMB Object Aggregated and presented as single namespace Node 2 Node 3 Node 4 Volume (2 x 2) (Distributed - Replicate) Cluster Architecture

Slide 5

Slide 5 text

Data Placement ➔ Uses hashing ➔ Hash ranges assigned to dirs ➔ Renames are special ➔ No metadata server ➔ Replication is synchronous ➔ Self healing (file repair) ➔ Optionally enforce quorum AFR /animals/cats/kitten.jpg 41 = hash_fn(kitten.jpg) DHT 0-49 0-49 AFR 50-99 50-99

Slide 6

Slide 6 text

FUSE: Filesystem in User Space https://en.wikipedia.org/wiki/Filesystem_in_Userspace#/media/File:FUSE_structure.svg CC BY-SA 3.0

Slide 7

Slide 7 text

Demo GlusterFS over FUSE

Slide 8

Slide 8 text

Image courtesy: https://website-humblec.rhcloud.com/wp-content/uploads/2014/04/screen2.jpg

Slide 9

Slide 9 text

➔ Userspace C library ➔ Applications link against libgfapi.so ➔ Reduced context switching ➔ Extend and break-free from POSIX ? libgfapi

Slide 10

Slide 10 text

Image courtesy: https://website-humblec.rhcloud.com/wp-content/uploads/2014/04/screen1.jpg

Slide 11

Slide 11 text

➔ Implemented using ctypes ➔ APIs mimic I/O methods of ‘os’ module ➔ But no monkey patching ➔ Available over PyPI ➔ Existing applications need code changes ➔ No Py3 support, yet libgfapi-python

Slide 12

Slide 12 text

Example and Demo libgfapi-python

Slide 13

Slide 13 text

# Create virtual mount v = Volume('10.7.1.99', 'data') v.mount() # Create directory v.mkdir('/dir1') # List directories v.listdir('/') # Create new file and write to it with v.fopen('/somefile.txt', 'w') as f: f.write("Winter is coming.") # Open and read file with v.fopen('/somefile.txt', 'r') as f: print f.read() # Delete file v.unlink('/somefile.txt') # Unmount v.umount() # Create directory os.mkdir('/dir1') # List directories os.listdir('/') # Create new file and write to it with open('/somefile.txt', 'w') as f: f.write("Winter is coming.") # Open and read file with open('/somefile.txt', 'r') as f: print f.read() # Delete file os.unlink('/somefile.txt')

Slide 14

Slide 14 text

Documentation and API Reference: http://libgfapi-python.rtfd.io Source: https://github.com/gluster/libgfapi-python Reach out to Gluster community: #gluster-dev on freenode [email protected]