JPGs and 3GPs and AMRs Oh My!



Similar documents
Scaling to Millions of Simultaneous Connections

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

ZEN LOAD BALANCER EE v3.02 DATASHEET The Load Balancing made easy

Optimizing Ext4 for Low Memory Environments

How to recover a failed Storage Spaces

Tuning Tableau Server for High Performance

Best Practices Guide Revision B. McAfee epolicy Orchestrator Software

GeoCloud Project Report USGS/EROS Spatial Data Warehouse Project

CLOUDDMSS: CLOUD-BASED DISTRIBUTED MULTIMEDIA STREAMING SERVICE SYSTEM FOR HETEROGENEOUS DEVICES

User Guide. Version 8.0 1

Accelerating Wordpress for Pagerank and Profit

Chapter 2 TOPOLOGY SELECTION. SYS-ED/ Computer Education Techniques, Inc.

WAN Optimization, Web Cache, Explicit Proxy, and WCCP. FortiOS Handbook v3 for FortiOS 4.0 MR3

Intro to Load-Balancing Tomcat with httpd and mod_jk

Alarms of Stream MultiScreen monitoring system

MailEnable Scalability White Paper Version 1.2

Oracle Exadata Database Machine for SAP Systems - Innovation Provided by SAP and Oracle for Joint Customers

virtualization.info Review Center SWsoft Virtuozzo (for Windows) //

Flow 3 Media Asset Management incorporating AirFlow and Automation

Amazon Cloud Storage Options

Introduction 1 Performance on Hosted Server 1. Benchmarks 2. System Requirements 7 Load Balancing 7

Application Delivery Networking

How To Plan A Desktop Workspace Infrastructure

HADOOP PERFORMANCE TUNING

IceWarp to IceWarp Server Migration

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

NoSQL Performance Test In-Memory Performance Comparison of SequoiaDB, Cassandra, and MongoDB

Release Notes. Upgrades to LifeSize UVC Video Center. New Features. LifeSize UVC Video Center Release: v2.1

OBSERVEIT DEPLOYMENT SIZING GUIDE

Wikimedia architecture. Mark Bergsma Wikimedia Foundation Inc.

Upgrading from a previous release of LifeSize Video Center to LifeSize UVC Video Center 2.0 is not supported in this release.

What s New in SharePoint 2016 (On- Premise) for IT Pros

Hitachi Data Migrator to Cloud Best Practices Guide

Big Fast Data Hadoop acceleration with Flash. June 2013

2 x 3.5-inch SATA 6Gb/s, SATA 3Gb/s hard drive. 1. The standard system is shipped without HDD. 2. For the HDD compatibility list, please

SharePoint 2013 Logical Architecture

Web Application Hosting Cloud Architecture

Hadoop: Embracing future hardware

Load Balancing and Sessions. C. Kopparapu, Load Balancing Servers, Firewalls and Caches. Wiley, 2002.

Scalability of web applications. CSCI 470: Web Science Keith Vertanen

Best Practices Guide. McAfee epolicy Orchestrator Software

Hardware Configuration Guide

SAP HANA - Main Memory Technology: A Challenge for Development of Business Applications. Jürgen Primsch, SAP AG July 2011

Propalms TSE Enterprise Deployment Server Sizing

Recording. Smart recording (depending on the camera models)

Simple Storage Service (S3)

Exploiting Remote Memory Operations to Design Efficient Reconfiguration for Shared Data-Centers over InfiniBand

CaaS SMB Pricing Guide

Managing a local Galaxy Instance. Anushka Brownley / Adam Kraut BioTeam Inc.

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

Where We Are. References. Cloud Computing. Levels of Service. Cloud Computing History. Introduction to Data Management CSE 344

Information. OpenScape Web Collaboration V7

IBM License Metric Tool Version Installing with embedded WebSphere Application Server

MAD2: A Scalable High-Throughput Exact Deduplication Approach for Network Backup Services

Zero Shell Implementation Scenarios

A Deduplication File System & Course Review

Streaming Stored Audio & Video

MICROSOFT OFFICE 365 MIGRATION 2013/05/13

1 Storage Devices Summary

Red Hat Network Satellite Management and automation of your Red Hat Enterprise Linux environment

Red Hat Satellite Management and automation of your Red Hat Enterprise Linux environment

Serving Media with NGINX Plus

Cloud Based Application Architectures using Smart Computing

Tableau Server Administrator Guide. Version 8.0.x

STORAGE CENTER WITH NAS STORAGE CENTER DATASHEET

SiteCelerate white paper

Building a large scale CDN with Apache Trafficserver. Jan van Doorn jan_vandoorn@cable.comcast.com

Sy Computing Services, Inc. TOP REASONS TO MOVE TO MICROSOFT EXCHANGE Prepared By:

Wowza Media Systems provides all the pieces in the streaming puzzle, from capture to delivery, taking the complexity out of streaming live events.

Lesson Plans Configuring Exchange Server 2007

AP ENPS ANYWHERE. Hardware and software requirements

DEPLOYMENT GUIDE Version 1.2. Deploying the BIG-IP System v10 with Microsoft IIS 7.0 and 7.5

SVN5800 Secure Access Gateway

Network Security Essentials Chapter 5

Best Practices for Managing Storage in the Most Challenging Environments

Sametime 9 Meetings deployment Open Mic July 23rd 2014

EdgeCast Networks Inc. Flash Media Streaming Administration Guide

OpenFlow with Intel Voravit Tanyingyong, Markus Hidell, Peter Sjödin

3.5in esata USB Dual Removable SATA RAID External Hard Drive Enclosure StarTech ID: S352U2RER

Understanding EMC Avamar with EMC Data Protection Advisor

MAGENTO HOSTING Progressive Server Performance Improvements

Performance Evaluation of VMXNET3 Virtual Network Device VMware vsphere 4 build

<Insert Picture Here> Oracle Database Directions Fred Louis Principal Sales Consultant Ohio Valley Region

From Firebird 1.5 to 2.5

Deploying Microsoft Exchange Server 2010 on the Hitachi Virtual Storage Platform with Hitachi Dynamic Tiering

The Most Powerful One Button HD Streaming, Recording and Auto-Publishing Solution. April White Paper

Office 365 Migration Performance & Server Requirements

VS-4112U-RP Pro+ Hardware Spec.

In Memory Accelerator for MongoDB

How to handle Out-of-Memory issue

SecurEnvoy Security Server. SecurMail Solutions Guide

Managing your Red Hat Enterprise Linux guests with RHN Satellite

Ignify ecommerce. Item Requirements Notes

SMB Direct for SQL Server and Private Cloud

Qsan AegisSAN Storage Application Note for Surveillance

Module 6. Designing and Deploying External Access. MVA Jump Start

Transcription:

JPGs and 3GPs and AMRs Oh My! Rick Reed WhatsApp Erlang Factory SF March 21, 2013 1

About me... Joined server team at WhatsApp in 2011 No prior Erlang experience Focus on systems scalability 2

Religious Moments 3

Religious Moments Pope Francis White smoke 4

Religious Moments Barcelona v. AC Milan Pope Francis White smoke 5

Pictures too... 6

Overview The multimedia problem Legacy implementation New architecture Challenges and workarounds Results and conclusions 7

The Problem Multimedia messages (MMS) Image Video Audio Some recorded on sender's phone, many not Group messaging Multi-platform support (transcoding) Store-and-forward, no archiving 8

The Problem A good (and fun) problem to have: More users More usage per user More multimedia as a % of usage per user 9

The Problem 10

The Problem Legacy system issues Scalability Ad-hoc transcoding Not Erlang 11

Goals Scalability Reliability Improved user experience 12

Legacy MMS Implementation Lighttpd + PHP Dual hexcore with 12 x SATA JBOD DNS round-robin No reference counting Time-based media expiration Client-initiated (server-hosted) transcoding 13

New MMS Architecture New features Resumable uploads and downloads Reference counting Upload de-dup Server-controlled transcoding Server-side trimming 14

New MMS Architecture New database Objects, References, Transcodings mnesia disc_copies tables Partitioned islands and fragmented tables All operations run async_dirty Use key hashing to collapse all ops per key to a single process 15

New MMS Architecture Mnesia Island 1 Partition 1 Partition 165, Frag 1, 17, 33, 49,1 Partition FragPartition 2, 18, 34, 50, 66, 1... replication Partition 2 Partition 166, Frag 2, 18, 34, 50,1 Partition FragPartition 1, 17, 33, 49, 65 1 Partition 4 Partition 6 Partition 8 Partition 3 Partition 5 Partition 7 Mnesia Island 2 Partition 9 Partition 173, Frag 9, 25, 41, 57,1 Partition FragPartition 10, 26, 42, 58,1 74,... Partition 11 Partition 13 Partition 15 replication Partition 10 Partition 174, Frag 10, 26, 42, 58,1 Partition Frag Partition 9, 25, 41, 57, 73, 1... Partition 12 Partition 14 Partition 16 16

New MMS Architecture Integration with Erlang messaging cluster Upload de-dup Upload load balancing Reference management (create, ack) 17

New MMS Architecture HTTP upload/download service Preserves some commonality w/ legacy system Good protocol support Content-type Ranges Some drawbacks SSL negotiation delay Support lacking on some client platforms 18

New MMS Architecture Web server: YAWS Nice balance of support for Serving media files Programmability Only handful of patches for our environment Runs embedded alongside other server procs 19

New MMS Architecture Object storage Simple file-per-object (FreeBSD UFS2) JBOD (directly attached to motherboard) Image: 6xSSD Audio/Video: 6xSATA Hashed directory tree (< 1k files in leaf dir) 16k blocksize Same storage used for transient message store Lots of experience (~4B cycles/day) Long-term predictability 20

New MMS Architecture Media identification erl_img triage (NIF) MediaInfo (fork) ffprobe (fork) Transcoding ffmpeg (fork) Custom clone of os:cmd to bypass shell 21

New MMS Architecture Proxy misdirected requests We hand out specific hostnames Objects may get archived or moved Acts as reverse proxy to host with content yaws_revproxy Somewhat difficult to set args correctly Otherwise, works great 22

New MMS Architecture Maintenance processes Reaper (drop ack'ed and old references) Reclaim (drop unreferenced objects w/ delay) Archiver (move old images to slow storage) Clean (remove stranded files) 23

New MMS Architecture Hardware Specs Dual octo-core E5-2690 (32 logical CPUs) 256GB RAM (128GB for A/V hosts) 6 x 800GB SSD (4TB SATA for A/V hosts) 2 x dual link-agg gig-e (public, private) 24

New MMS Architecture client chat chat chat chat chat chatd wa chat protocol https upload/download Erlang distribution images/db yaws mmd yaws mmd yaws mmd yaws mnesiammd yaws mnesiammd yaws mnesiammd yaws mnesiammd stud yaws mmd mnesiammd mnesia mnesia mnesia mnesia yaws audio/video yaws mmd yaws mmd yaws mmd yaws mnesiammd yaws mnesiammd yaws mnesiammd yaws mnesiammd stud yaws mmd mnesiammd mnesia mnesia mnesia yaws archiving ssd sata 25

Challenges and Workarounds SSL Connection bottleneck (throughput < RSA rate) Offloaded SSL termination to stud Patched YAWS to accept HaProxy-style header Request rate now limited by RSA rate Need multiple loopback aliases for >64k ports 26

Challenges and Workarounds sendfile sendfile & async threads don't mix On FreeBSD, at least Long BEAM stalls Tried both file:sendfile and YAWS driver Disabled sendfile in YAWS Run +A 1024 Plenty of memory bandwidth on our hosts 27

Challenges and Workarounds Mnesia table sizes ~250M objects, ~750M references per host Limits to how much RAM we can stuff in a host Moved from naïve/native to packed format Packed record fields into 60-bit integers Packed {bin1, bin2} key into <<bin1, bin2>> encrypt(filehash) <=> id instead of hash() => id Record storage size reduced ~45% 28

Challenges and Workarounds Each host: ================================================================================ Active Tables Local Copy Type Records Bytes -------------------------------------------------------------------------------mmd_obj2(128) unknown 242,325,152 46,859,527,336 mmd_reclaim disc_copies 6,301,921 930,213,336 mmd_ref3(128) unknown 759,076,825 138,261,758,224 mmd_upload disc_copies 2,069,134 413,827,448 mmd_xcode2(128) unknown 8,477,025 2,648,887,144 schema disc_copies 387 444,384 -------------------------------------------------------------------------------Total 1,018,250,444 189,114,657,872 ================================================================================ 29

Challenges and Workarounds Slow reference checking Ordered set keyed by Id & Ref concatenated Naïve: length(get_refs(id)) == 0 Fast: case mnesia:next(tab, Id) of <<Id:?ID_LEN/binary, _RefId:?REF_LEN/binary>> true _ false end 30

Challenges and Workarounds mnesia:select by background procs Returned lists of >>1M entries Originally put in scratch ets table for iteration Select with continuation much better 31

Challenges and Workarounds Db migrations Converting record formats while online Lazy migration: Read: read(new), if missing read(old) Write: write(new), delete(old) Delete: delete(new), delete(old) No transactions Hash key to specific process on specific host Final batch conversion, then normal behavior 32

Challenges and Workarounds Bandwidth Users hungry to consume and share media Single host easily fills 2x1g aggregated uplink Dealing with soaring bandwidth bill Cap and manage various media parameters (video dimensions/bitrate/framerate, audio sampling rate/bitrate, etc.) Count downloads and force down-conversion 33

Challenges and Workarounds Lingering issues: Storage redundancy Memory leakage on db hosts (fragmentation?) mnesia schema ops under load Tweaking transcodings for playback issues Managing transcode CPU Capacity planning/management 34

Challenges and Workarounds 35

Challenges and Workarounds 36

Results Peak Scalability 214M images in a day 8.8K images/sec downloaded 29 Gb/sec output bandwidth 37

Results Holiday week 38

Results Erlang just fine for pushing (lots of) bytes But not good at everything 39

Results Example: Great for transcode configs Various transcoding tweaks require code Ability to deploy changes quickly Raises value of server-initiated transcodes 40

Results get_download_defaults (#mmd_client{os = android}, Type, video) #mmd_parms{type=opt_default(type, [video_mp4, video_3gp]), vcodec=[h264, mpeg4, h263], width=720, height=480, vbitrate=?vbitrate_max, acodec=[aac, amrnb]}; get_download_defaults (#mmd_client{os = iphone, device = Device}, Type, video) Parms = #mmd_parms{type=opt_default(type, [video_mp4, video_quicktime]), vcodec=[h264, mpeg4], width=480, height=360, fps=15, vbitrate=?vbitrate_max, acodec=aac}, if Device =:= "iphone_5"; Device =:= "iphone_4s"; Device =:= "iphone_4"; Device =:= "iphone_4_vzw" Parms#mmd_parms{width=1280, height=720, fps=30}; true Parms end; 41

Results 42

Questions? rr@ whatsapp.com 43

The Problem 44

Challenges and Workarounds 45