Kit Chan (kichan@yahoo-inc.com) ATS Lua Plugin Kit Chan (kichan@yahoo-inc.com) Hi, My name is kit.

Slides:



Advertisements
Similar presentations
IS 6116 Introduction – 10 Jan Lecturer Details Aonghus Sugrue Website: aonghussugrue.wordpress.com
Advertisements

HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation
Other Web Application Development Technologies. PHP.
Building and using REST information services Rion Dooley.
Certification Test Tool Jon Wheeler Test Lead Microsoft Corporation.
WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.
Lecture 11 Server Side Interaction
© Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Pronq IDE – Collaboration.
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1Proprietary and Confidential AirVantage API – Getting started David SCIAMMA – June 13th 2014.
1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:
BROCADE ADX OPENSCRIPT March Derek Kang Solutions
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Technology Overview JAVA Servlets CS-611 S. Witherspoon.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Proxy Cache Leonid Romanovsky Olga Fomenko Winter 2003 Instructor: Konstantin Sinyuk.
Apache Jakarta Tomcat Suh, Junho. Road Map Tomcat Overview Tomcat Overview History History What is Tomcat? What is Tomcat? Servlet Container.
First Indico Workshop Conversion Server Thomas Baron May 2013 CERN.
Intro To JMeter Christian Desserich Testing a Web-Based Application.
IT 210 The Internet & World Wide Web introduction.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,

AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
1 Chapter 2 & Chapter 4 §Browsers. 2 Terms §Software §Program §Application.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Putting What We Learned Into Context – WSGI and Web Frameworks A290/A590, Fall /16/2014.
Cloud Standard API and Contextualization
Scalable Web Server on Heterogeneous Cluster CHEN Ge.
Chapter 6 Server-side Programming: Java Servlets
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
mysql-proxy By Farhad Saberi - Overview and architecture - Making The case for a proxy - Lua - Lua examples - The admin interface - currently.
What’s new in Kentico CMS 5.0 Michal Neuwirth Product Manager Kentico Software.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
3.14 Work List IOC Core Channel Access. Changes to IOC Core Online add/delete of record instances Tool to support online add/delete OS independent layer.
® IBM Software Group © 2007 IBM Corporation Best Practices for Session Management
Module 3: Using Microsoft.NET- Based Languages. Overview Overview of the.NET-Based Languages Comparison of the.NET-Based Languages.
Apache JMeter By Lamiya Qasim. Apache JMeter Tool for load test functional behavior and measure performance. Questions: Does JMeter offers support for.
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
1 MSRBot Web Crawler Dennis Fetterly Microsoft Research Silicon Valley Lab © Microsoft Corporation.
Security Issues with PHP  PHP installation  PHP programming Willa Zhu & Eugene Burger.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
ICM – API Server & Forms Gary Ratcliffe.
Traffic Server APIs Brian Geffon LinkedIn Nov 16, 2015.
Web Technologies Lecture 6 State preservation. Motivation How to keep user data while navigating on a website? – Authenticate only once – Store wish list.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
Web Cache. What is Cache? Cache is the storing of data temporarily to improve performance. Cache exist in a variety of areas such as your CPU, Hard Disk.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
Varnish Cache and its usage in the real world Ivan Chepurnyi Owner EcomDev BV.
Autodesk Dev Days 2015 The road ahead DevDays 2015
Web fundamentals: Clients, Servers, and Communication
WWW and HTTP King Fahd University of Petroleum & Minerals
Understanding SOAP and REST calls The types of web service requests
Open Source distributed document DB for an enterprise
Platform as a Service.
Processes The most important processes used in Web-based systems and their internal organization.
Test Case Structure Test Case Module(depend on framework) MocoServer
PHP / MySQL Introduction
Evaluating Transaction System Performance
Google App Engine Ying Zou 01/24/2016.
Module 10: Implementing Managed Code in the Database
Web Application Development Using PHP
Plug-In Architecture Pattern
ASP.NET Core Middleware Fundamentals
Presentation transcript:

Kit Chan (kichan@yahoo-inc.com) ATS Lua Plugin Kit Chan (kichan@yahoo-inc.com) Hi, My name is kit.

Apache Traffic Server [1] ATS - fast, scalable and extensible HTTP/1.1 compliant caching proxy server C APIs Http Header Manipulation Http Transaction Statistics Management More!!!

Hooks & Plugins [1] Plugins – implemented as Continuations Triggered into Activity through Hooks attached to various state of HTTP transaction

Writing Plugins Continuation is hard to follow C/C++ code “Gotos with arguments” [2] C/C++ code Memory management Complex data structure header_rewrite plugin [3] Attempt to save you from writing plugins for simple tasks Use config files to do simple tasks, such as adding/removing headers No unit test framework Hard to use – not a real language # sample header_rewrite conf # add Cache-Control header cond %{READ_RESPONSE_HEADER_HOOK} [AND] rm-header Cache-Control add-header Cache-Control “max-age=0, public” [L]

Varnish & VCL Varnish [4] – another popular HTTP caching proxy server Major competitor to ATS VCL [5] – Varnish Configuration Language DSL to configure Varnish Things you can do “direct certain requests to certains backends” “alter the requests and the responses” Major advantage over others !!! [6] [7] //sample VCL to //remove cookie from image reqs sub vcl_recv { if (req.url ~ "^/images") { unset req.http.cookie; }

Leveling the Playing Field – Lua [8] Scripting Language Simple to learn and use Abstract user from variable types and memory management Light weight library ~ 200KB Extensible through C APIs Easy to be embedded into applications, such as ATS Uses – Redis, MySQL Proxy, many game engines

Plugin Implementation Details ATS C APIs are exposed as Lua Functions under the ‘ts’ module Loaded as library to the core When ATS starts, ATS Creates and inits Lua VM Load the specified Lua script and registered its global functions and variables in Lua VM Register hooks with specific or designated functions in the Lua script During a HTTP transaction handled by ATS, Registered Lua functions for HTTP transaction hooks will be triggered

More Details Open Source Documentation [11] ATS 4 ATS 5 Contributed by Yahoo and Taobao [9][10] Adoptions by community is increasing Documentation [11] ATS 4 Required lua 5.1.4 shared library ATS 5 Luajit 2.0.3 [12] is compiled into ATS core Compatible with lua 5.1.x Luajit has better performance but a 2GB limit on memory PANIC: unprotected error in call to Lua API (not enough memory)

Sample Lua Scripts for ATS -- Lua script to add CORS header to response -- for a request with matching Referer header function send_response() if ts.ctx['origin'] == nil then ts.debug("invalid referer"); else ts.client_response.header['Access-Control-Allow-Origin'] = ts.ctx['origin'] end return 0 function do_global_read_request() local referer = ts.client_request.header.Referer if referer == nil then ts.ctx['origin'] = nil ts.ctx['origin'] = string.match(referer, "http://%a+.yahoo.com") ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)

Coding Guidelines Due to the 2GB limit with luajit, we should not keep large amount of data in arrays Functionality should be grouped in module -- cors_lib.lua contains module for adding CORS resp header for a request with matching Referer header local cors_lib = {} function cors_lib.send_response() ts.client_response.header['Access-Control-Allow-Origin'] = ts.ctx['origin‘] return 0 end function cors_lib.execute() local referer = ts.client_request.header.Referer if referer ~= nil then ts.ctx['origin'] = string.match(referer, "http://%a+.yahoo.com") if ts.ctx['origin'] ~= nil then ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response) return cors_lib

Coding Guidelines A main lua script can then be used to add these modules and use their function -- main lua script to be refererd by ATS -- read in the module defined in separate files ts.add_package_path('/home/y/var/media/cors_lib.lua') local cors_lib = require “cors_lib" function do_global_read_request() cors_lib.execute() return 0 end

Unit Test Framework Using lunit [13] Need to provide stubs/mocks for functions in ‘ts’ module (ts.lua) require "lunit" ts = require 'ts' local cors_lib = require ‘cors_lib' module( “cors_testcase", lunit.testcase ) function test_failure() ts.client_request.header[‘Referer’] = ‘http://news.yahoo.com’ cors_lib.execute() assert_equal(‘http://news.yahoo.com’, ts.client_response.header[‘Access-Control-Allow-Origin ‘Matched’) end

Performance Implication Test setup proxying 6K object for Origin server with sufficient capacity header_rewrite / lua scripts provided to add response header Performance Implication is negligible Requests/s Latency (ms) CPU Util ATS4 (No Plugin) 5494 25 85% ATS4 with header_rewrite 5791 90% ATS4 with Lua 5776 27 ATS5 (No plugin) 5676 33 93% ATS5 with header_rewrite 5213 30 95% ATS5 with Lua 5210 35 CONFIDENTIAL & PROPRIETARY

Futures Short term Longer term More Lua functions covering more ATS C APIs Security/Sandbox/safety? More performance analysis – when will GC run? / Best Practices Longer term Deeper integration with the ATS core for Lua Replace configuration files for ATS

Refereces ATS - https://docs.trafficserver.apache.org/en/latest/sdk/how-to-create-trafficserver-plugins.en.html Computational Continuations - http://www.jquigley.com/files/talks/continuations.pdf header_rewrite - https://docs.trafficserver.apache.org/en/latest/reference/plugins/header_rewrite.en.html Varnish - https://www.varnish-cache.org/ VCL - https://www.varnish-cache.org/docs/4.0/users-guide/vcl.html http://www.slideshare.net/bryan_call/choosing-a-proxy-server-apachecon-2014 (Slides 47) http://www.bizety.com/2014/06/11/interview-founder-of-varnish-software/ Lua - http://www.lua.org/ TS-2335 - https://issues.apache.org/jira/browse/TS-2335 TS-2555 - https://issues.apache.org/jira/browse/TS-2555 ATS Lua Pugin Documentation - https://docs.trafficserver.apache.org/en/latest/reference/plugins/ts_lua.en.html Luajit - http://luajit.org/luajit.html Lunit - http://www.mroth.net/lunit/

CONFIDENTIAL & PROPRIETARY