SlideShare a Scribd company logo
APACHE SLING & FRIENDS TECH MEETUP
BERLIN, 25-27 SEPTEMBER 2017
Building an Apache Sling Rendering Farm
Bertrand Delacretaz
@bdelacretaz
Sling committer and PMC member

Principal Scientist, Adobe AEM team
slides revision 2017-09-25
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 2
What are we building?setting the stage
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 3
How is Sling used today?
Load

BalancingThe Web
Publishing Instances
Sling instances dedicated to single tenants or “friendly” tenants.
Rendering
+ Caching
Content

Repository
Rendering
+ Caching
Content

Repository
Rendering
+ Caching
Content

Repository
Rendering
+ Caching
Content

Repository
Content

Repository
Authoring
Content Distribution
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 4
A Massive Sling Rendering/Processing Farm?
Content

Repository
Resource

Resolution
Scripting +

Rendering
Resource

Resolution
Resource

Resolution
Resource

Resolution
Scripting +

Rendering
Scripting +

Rendering
Scripting +

Rendering
Load

Balancing
Load

Balancing
Elastic scaling at each stage
Multiple developers (“tenants”) see their own world only
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 5
Federated ServicesThis 2017 after all
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 6
Content

Repository
Resource

Resolver
Scripting and
Rendering
Script
Resolver
HTTP

front-end Sling Engine
Microservices!
Nice and trendy,
but will that
perform?
HTTP
HTTP
HTTP HTTP HTTP
HTTP
Each component is an independent HTTP-based service, aka “religious microservices”
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 7
The Sling PipelineFaithfully serving requests since 2007!
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 8
Content

Repository
Resource

Resolver
Scripting and
Rendering
Script
Resolver
Resource ScriptRequest Output
Sling Request Processing Pipeline
1 2 3 4
Conceptually, the request hits the repository first, to get the Resource.
Scripts and Servlets are equivalent, considering scripts only here.
All in-memory and in-process!
sling:include
5..N
content aggregation!
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 9
Content

Repository
Scripting and
Rendering
Script
Resolver
Scripts
Output
Federated Services Friendly?
Resource

Resolver
Content
Aggregator
Aggregated

Content
Request
Process boundaries
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 10
Reasonably Federated?Can we get isolation AND performance?
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 11
HTTP

front-end
Reasonably Federated Sling Rendering Farm?
Aggregated

Content
Content

Repository
Resource

Resolver
Content
Aggregator
Content Provider

Service
Content Rendering

Service
Scripting and
Rendering
Script
Resolver
Scripts

Repository
Output
It’s still mostly Sling, with the addition of a
(scripted?) content aggregation step.
Federated services provide more deployment and
scaling options.
Sandboxed
Execution
Isolated
Content
Sandboxed
Execution
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 12
Sandboxing & IsolationHow?
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 13
Sandboxing & Isolation?
Scripting and
Rendering
Sandboxed
Execution
Content

Repository
Isolated
Content
Content
Aggregator
Sandboxed
Execution
Repository Access Control
can work but require a dynamic
search path in Sling, see our
experiments. Impacts caching, and
mapping of incoming to resource
paths is needed.Tried and tested.
Repository jails look possible
with probable impact on Sling
internals. Same with multiple
SlingRepository services. New
and more like a blacklist.
Custom, restricted languages
are the safest? HTL (Use-API?),
Handlebars?
Sandboxing Nashorn
(JavaScript) looks possible but not
ideal, see our experiments.
Sandboxing Java is not realistic-
IBM canceled multi tenant JVM
project for example.
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 14
But it’s a VM, right?
Oak
Libraries Sling Engine
JavaVirtual Machine
content
Oak
Libraries Sling Engine
JavaVirtual Machine
content
Oak
Libraries Sling Engine
JavaVirtual Machine
content
Perfect isolation!
Java classes

memory space
Application

memory space
Java classes

memory space
Application

memory space
Java classes

memory space
Application

memory space
But suboptimal use of resources!
(and containers wouldn’t help)
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 15
Sandboxing scripting languages?
<%
var length = 0;
if (request.getRequestParameter("file") != null) {
var file = null;
// store file
var reqPara = request.getRequestParameter("file");
var is = reqPara.getInputStream();
file = Packages.java.io.File.createTempFile("posttest", ".txt");
var fout = new Packages.java.io.FileOutputStream(file);
var c;
while ((c = is.read()) != -1) {
fout.write(c);
}
fout.close();
// read length
length = file.length();
}
%>
OS
Resources
Infinite
Loops
Java classes
& services
Memory

Usage?
Many things need to be limited.

Whitelist approach is much safer -> custom languages?

HTL inherently sandboxed, except its Use-objects
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 16
Containers?
Oak
Libraries Sling Engine
OS container
content
Java classes

memory space
Application

memory space
SMALL!
Shared Memory
Pools, Caches etc.
memory
Oak
Libraries Sling Engine
OS container
content
Java classes

memory space
Application

memory space
SMALL!
Oak
Libraries Sling Engine
OS container
content
Java classes

memory space
Application

memory space
SMALL!
Same problem as multiple JVMs
Sharing caches, compiled scripts etc. can be a pragmatic solution.
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 17
What do we do?
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 18
Hybrid Sling Rendering Farm
Annotated
Aggregated
Content
HTTP

front-end
HTTP

routing
Scripting +
Rendering
Script
Resolver scripts
Shared Services
Custom
Code
Script
Resolver scripts
Tenant-Specific Services
servletscontent
Resource

Resolver
Content
Aggregator
Oak
Libraries
Shared Services
Sandboxed
Execution
New

Component
Content-driven
routing
Isolated

Content
Dynamic
Search Path
Provides the flexibility of Sling via tenant-specific services and dynamic routing.
Uses shared services for the common parts.
Allows for billable options depending on the actual routing.
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 19
Experimentsbuilding blocks that might be reusable
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 20
Resolving new types of scripts Experim
ent
Script
Resolver
Client

GET
Request
Wrapped

AGG
Request
Wrap the request to make it appear as an
AGG (*) request and pass that to the
Sling ServletResolver.
Adapt the return SlingScript to an
InputStream to read its text.
(*) or any other non-existent HTTP verb.
Content

Repository
/apps

/myapp
/AGG.js
AGG.js

script

text
Code at https://github.com/bdelacretaz/sling-adaptto-2017 (ContentBVP.java)
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 21
Resolving a SLING-CONTENT script Experim
ent
Code at https://github.com/bdelacretaz/sling-adaptto-2017 (ContentBVP.java)
String getAggregatorScript(SlingHttpServletRequest r) {
String result = null;
Servlet s =
servletResolver.resolveServlet(
new ChangeMethodRequestWrapper(r, "SLING-CONTENT"));
if(s instanceof SlingScript) {
InputStream is = ((SlingScript)s).getScriptResource()
.adaptTo(InputStream.class); }
if(is != null) {
result = IOUtils.toString(is)
}
}
return result;
}
adaptTo() Bonus Points!
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 22
Content Aggregation with Sling Query Experim
entvar $ = Packages.org.apache.sling.query.SlingQuery.$
var SearchStrategy =
Packages.org.apache.sling.query.api.SearchStrategy
var resourceResolver = resource.getResourceResolver()
var result = {
siblings : $(resource).siblings(),
rootChildren : $(resource).parents().last().children(),
queryResult :
$(resourceResolver)
.searchStrategy(SearchStrategy.QUERY)
.find("nt:base[title=foo]")
} Used in a BindingsValuesProvider?
Or in a custom json renderer servlet which runs this script.
Inherently sandboxed due to custom language.
https://sling.apache.org/documentation/bundles/sling-query.html
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 23
Dynamic scripts/servlet search path Experim
entif(dynamicServletResolver.canResolve(resource)) {
servlet = dynamicServletResolver.resolveServlet(request);
} else {
…existing resolver code
}
A fairly simple change to the SlingServletResolver - should evolve
into a real extension point if desired, and probably get the
request as well.
Tested in SLING-4386 - another multitenant experiment which
provides tenant-specific scripts but no real isolation.
Currently requires disabling the servlet resolution cache.
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 24
Nashorn (JavaScript) sandboxing (Java Delight) Experim
entNashornSandbox {
allow(final Class<?> clazz);
injectGlobalVariable(String variableName, Object object);
setMaxCPUTime(long limitMsec);
Object eval(final String javaScriptCode);
allowPrintFunctions(boolean v);
allowReadFunctions(boolean v);
...more allow functions
// $ARG, $ENV, $EXEC...
allowGlobalsObjects(final boolean v);
}
Uses Nashorn’s ClassFilter to block Java classes
Sandboxing rewrites standard methods + user code- > blacklisting, not ideal
https://github.com/javadelight/delight-nashorn-sandbox (Java Delight Suite)
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 25
CODAwhere to now?
Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 26
CODA
Thank you for attending!
I’m Bertrand Delacretaz (@bdelacretaz)
In-memory nature of Sling is an important
differentiator, in good and bad ways!
Hybrid Rendering Farm promising - do you need it?
Sandboxing is difficult, whitelisting much
preferred, custom languages?
Reusable

experiments?

More Related Content

What's hot (20)

PDF
Rh developers fat jar smackdown
Red Hat Developers
 
PDF
DCSF19 Tips and Tricks of the Docker Captains
Docker, Inc.
 
PDF
BBL Premiers pas avec Docker
kanedafromparis
 
PDF
Continuous Integration: SaaS vs Jenkins in Cloud
Ideato
 
PDF
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
PPTX
Writing a Gem with native extensions
Tristan Penman
 
PDF
Docker in practice
Jonathan Giannuzzi
 
PDF
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
PDF
Streamline your development environment with docker
Giacomo Bagnoli
 
PPTX
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 
PPTX
Running Docker in Development & Production (#ndcoslo 2015)
Ben Hall
 
PPTX
Docker for Developers - Sunshine PHP
Chris Tankersley
 
PPTX
Lessons from running potentially malicious code inside Docker containers
Ben Hall
 
PDF
DocuOps & Asciidoctor in a JVM World
Schalk Cronjé
 
PPT
Build service with_docker_in_90mins
Larry Cai
 
PDF
Docker perl build
Workhorse Computing
 
PDF
Check the version with fixes. Link in description
Przemyslaw Koltermann
 
PPTX
Docker
Cary Gordon
 
PDF
Hands on Docker - Launch your own LEMP or LAMP stack
Dana Luther
 
PPTX
Cloud hybridation leveraging on Docker 1.12
Ludovic Piot
 
Rh developers fat jar smackdown
Red Hat Developers
 
DCSF19 Tips and Tricks of the Docker Captains
Docker, Inc.
 
BBL Premiers pas avec Docker
kanedafromparis
 
Continuous Integration: SaaS vs Jenkins in Cloud
Ideato
 
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
Writing a Gem with native extensions
Tristan Penman
 
Docker in practice
Jonathan Giannuzzi
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
Streamline your development environment with docker
Giacomo Bagnoli
 
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 
Running Docker in Development & Production (#ndcoslo 2015)
Ben Hall
 
Docker for Developers - Sunshine PHP
Chris Tankersley
 
Lessons from running potentially malicious code inside Docker containers
Ben Hall
 
DocuOps & Asciidoctor in a JVM World
Schalk Cronjé
 
Build service with_docker_in_90mins
Larry Cai
 
Docker perl build
Workhorse Computing
 
Check the version with fixes. Link in description
Przemyslaw Koltermann
 
Docker
Cary Gordon
 
Hands on Docker - Launch your own LEMP or LAMP stack
Dana Luther
 
Cloud hybridation leveraging on Docker 1.12
Ludovic Piot
 

Similar to Building an Apache Sling Rendering Farm (20)

PDF
Can we run the Whole Web on Apache Sling?
Bertrand Delacretaz
 
PDF
Effective Web Application Development with Apache Sling
Robert Munteanu
 
PPT
Build Your Own CMS with Apache Sling
Bob Paulin
 
PDF
RESTFul development with Apache sling
Sergii Fesenko
 
PPTX
Rest and Sling Resolution
DEEPAK KHETAWAT
 
PPTX
Shooting rabbits with sling
Tomasz Rękawek
 
PDF
CIRCUIT 2015 - 10 Things Apache Sling Can Do
ICF CIRCUIT
 
PPTX
Content-centric architectures - case study : Apache Sling
Fabrice Hong
 
PDF
Modern operations with Apache Sling (2014 adaptTo version)
Bertrand Delacretaz
 
PPTX
Integration patterns in AEM 6
Yuval Ararat
 
PDF
Using OSGi for script deployment in Apache Sling
Radu Cotescu
 
PDF
Apache Sling
nobby
 
PPTX
Sling pipes
Ankit Gubrani
 
PDF
Content-Centric Web Development with Apache Sling
Koen Van Eeghem
 
PDF
Apache Sling Scripting Reloaded
Radu Cotescu
 
PDF
Effective web application development with Apache Sling
Robert Munteanu
 
ODP
Server-side OSGi with Apache Sling (Jazoon 2010)
Felix Meschberger
 
PPTX
EPAM IT WEEK: AEM & TDD. It's so boring...
Andrew Manuev
 
PDF
Escape the defaults - Configure Sling like AEM as a Cloud Service
Robert Munteanu
 
ODP
Server-side OSGi with Apache Sling (OSGiDevCon 2011)
Felix Meschberger
 
Can we run the Whole Web on Apache Sling?
Bertrand Delacretaz
 
Effective Web Application Development with Apache Sling
Robert Munteanu
 
Build Your Own CMS with Apache Sling
Bob Paulin
 
RESTFul development with Apache sling
Sergii Fesenko
 
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Shooting rabbits with sling
Tomasz Rękawek
 
CIRCUIT 2015 - 10 Things Apache Sling Can Do
ICF CIRCUIT
 
Content-centric architectures - case study : Apache Sling
Fabrice Hong
 
Modern operations with Apache Sling (2014 adaptTo version)
Bertrand Delacretaz
 
Integration patterns in AEM 6
Yuval Ararat
 
Using OSGi for script deployment in Apache Sling
Radu Cotescu
 
Apache Sling
nobby
 
Sling pipes
Ankit Gubrani
 
Content-Centric Web Development with Apache Sling
Koen Van Eeghem
 
Apache Sling Scripting Reloaded
Radu Cotescu
 
Effective web application development with Apache Sling
Robert Munteanu
 
Server-side OSGi with Apache Sling (Jazoon 2010)
Felix Meschberger
 
EPAM IT WEEK: AEM & TDD. It's so boring...
Andrew Manuev
 
Escape the defaults - Configure Sling like AEM as a Cloud Service
Robert Munteanu
 
Server-side OSGi with Apache Sling (OSGiDevCon 2011)
Felix Meschberger
 
Ad

More from Bertrand Delacretaz (20)

PDF
VanillaJS & the Web Platform, a match made in heaven?
Bertrand Delacretaz
 
PDF
Surviving large online communities with conciseness and clarity
Bertrand Delacretaz
 
PDF
The Moving House Model, adhocracy and remote collaboration
Bertrand Delacretaz
 
PDF
Open Source Changes the World!
Bertrand Delacretaz
 
PDF
How to convince your left brain (or manager) to follow the Open Source path t...
Bertrand Delacretaz
 
PDF
L'Open Source change le Monde - BlendWebMix 2019
Bertrand Delacretaz
 
PDF
Shared Neurons - the Secret Sauce of Open Source communities?
Bertrand Delacretaz
 
PDF
State of the Feather - ApacheCon North America 2018
Bertrand Delacretaz
 
PDF
Karate, the black belt of HTTP API testing?
Bertrand Delacretaz
 
PDF
Open Source at Scale: the Apache Software Foundation (2018)
Bertrand Delacretaz
 
PDF
They don't understand me! Tales from the multi-cultural trenches
Bertrand Delacretaz
 
PDF
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Bertrand Delacretaz
 
PDF
Project and Community Services the Apache Way
Bertrand Delacretaz
 
PDF
La Fondation Apache - keynote au Paris Open Source Summit 2017
Bertrand Delacretaz
 
PDF
Asynchronous Decision Making - FOSS Backstage 2017
Bertrand Delacretaz
 
PDF
Who needs meetings? Asynchronous Decision Making to the rescue
Bertrand Delacretaz
 
PDF
Simple software is hard...don't give up!
Bertrand Delacretaz
 
PDF
I will NOT attend your meeting - I'm an Open Source person
Bertrand Delacretaz
 
PDF
Open Development in the Enterprise, 19 minutes 2016 version
Bertrand Delacretaz
 
PDF
RESTful OSGi middleware for NoSQL databases with Docker
Bertrand Delacretaz
 
VanillaJS & the Web Platform, a match made in heaven?
Bertrand Delacretaz
 
Surviving large online communities with conciseness and clarity
Bertrand Delacretaz
 
The Moving House Model, adhocracy and remote collaboration
Bertrand Delacretaz
 
Open Source Changes the World!
Bertrand Delacretaz
 
How to convince your left brain (or manager) to follow the Open Source path t...
Bertrand Delacretaz
 
L'Open Source change le Monde - BlendWebMix 2019
Bertrand Delacretaz
 
Shared Neurons - the Secret Sauce of Open Source communities?
Bertrand Delacretaz
 
State of the Feather - ApacheCon North America 2018
Bertrand Delacretaz
 
Karate, the black belt of HTTP API testing?
Bertrand Delacretaz
 
Open Source at Scale: the Apache Software Foundation (2018)
Bertrand Delacretaz
 
They don't understand me! Tales from the multi-cultural trenches
Bertrand Delacretaz
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Bertrand Delacretaz
 
Project and Community Services the Apache Way
Bertrand Delacretaz
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
Bertrand Delacretaz
 
Asynchronous Decision Making - FOSS Backstage 2017
Bertrand Delacretaz
 
Who needs meetings? Asynchronous Decision Making to the rescue
Bertrand Delacretaz
 
Simple software is hard...don't give up!
Bertrand Delacretaz
 
I will NOT attend your meeting - I'm an Open Source person
Bertrand Delacretaz
 
Open Development in the Enterprise, 19 minutes 2016 version
Bertrand Delacretaz
 
RESTful OSGi middleware for NoSQL databases with Docker
Bertrand Delacretaz
 
Ad

Recently uploaded (20)

PPTX
ipv6 very very very very vvoverview.pptx
eyala75
 
PPTX
Presentation on Social Media1111111.pptx
tanamlimbu
 
PDF
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PPTX
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
PDF
Internet Governance and its role in Global economy presentation By Shreedeep ...
Shreedeep Rayamajhi
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PDF
123546568reb2024-Linux-remote-logging.pdf
lafinedelcinghiale
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PDF
Digital Security in 2025 with Adut Angelina
The ClarityDesk
 
PPTX
Simplifying and CounFounding in egime.pptx
Ryanto10
 
PPTX
英国学位证(RCM毕业证书)皇家音乐学院毕业证书如何办理
Taqyea
 
PPTX
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
PPTX
Cost_of_Quality_Presentation_Software_Engineering.pptx
farispalayi
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
unit 2_2 copy right fdrgfdgfai and sm.pptx
nepmithibai2024
 
PPT
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
PDF
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
PPT
introduction to networking with basics coverage
RamananMuthukrishnan
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
ipv6 very very very very vvoverview.pptx
eyala75
 
Presentation on Social Media1111111.pptx
tanamlimbu
 
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
Internet Governance and its role in Global economy presentation By Shreedeep ...
Shreedeep Rayamajhi
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
123546568reb2024-Linux-remote-logging.pdf
lafinedelcinghiale
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
Digital Security in 2025 with Adut Angelina
The ClarityDesk
 
Simplifying and CounFounding in egime.pptx
Ryanto10
 
英国学位证(RCM毕业证书)皇家音乐学院毕业证书如何办理
Taqyea
 
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
Cost_of_Quality_Presentation_Software_Engineering.pptx
farispalayi
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
unit 2_2 copy right fdrgfdgfai and sm.pptx
nepmithibai2024
 
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
introduction to networking with basics coverage
RamananMuthukrishnan
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 

Building an Apache Sling Rendering Farm

  • 1. APACHE SLING & FRIENDS TECH MEETUP BERLIN, 25-27 SEPTEMBER 2017 Building an Apache Sling Rendering Farm Bertrand Delacretaz @bdelacretaz Sling committer and PMC member
 Principal Scientist, Adobe AEM team slides revision 2017-09-25
  • 2. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 2 What are we building?setting the stage
  • 3. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 3 How is Sling used today? Load
 BalancingThe Web Publishing Instances Sling instances dedicated to single tenants or “friendly” tenants. Rendering + Caching Content
 Repository Rendering + Caching Content
 Repository Rendering + Caching Content
 Repository Rendering + Caching Content
 Repository Content
 Repository Authoring Content Distribution
  • 4. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 4 A Massive Sling Rendering/Processing Farm? Content
 Repository Resource
 Resolution Scripting +
 Rendering Resource
 Resolution Resource
 Resolution Resource
 Resolution Scripting +
 Rendering Scripting +
 Rendering Scripting +
 Rendering Load
 Balancing Load
 Balancing Elastic scaling at each stage Multiple developers (“tenants”) see their own world only
  • 5. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 5 Federated ServicesThis 2017 after all
  • 6. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 6 Content
 Repository Resource
 Resolver Scripting and Rendering Script Resolver HTTP
 front-end Sling Engine Microservices! Nice and trendy, but will that perform? HTTP HTTP HTTP HTTP HTTP HTTP Each component is an independent HTTP-based service, aka “religious microservices”
  • 7. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 7 The Sling PipelineFaithfully serving requests since 2007!
  • 8. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 8 Content
 Repository Resource
 Resolver Scripting and Rendering Script Resolver Resource ScriptRequest Output Sling Request Processing Pipeline 1 2 3 4 Conceptually, the request hits the repository first, to get the Resource. Scripts and Servlets are equivalent, considering scripts only here. All in-memory and in-process! sling:include 5..N content aggregation!
  • 9. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 9 Content
 Repository Scripting and Rendering Script Resolver Scripts Output Federated Services Friendly? Resource
 Resolver Content Aggregator Aggregated
 Content Request Process boundaries
  • 10. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 10 Reasonably Federated?Can we get isolation AND performance?
  • 11. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 11 HTTP
 front-end Reasonably Federated Sling Rendering Farm? Aggregated
 Content Content
 Repository Resource
 Resolver Content Aggregator Content Provider
 Service Content Rendering
 Service Scripting and Rendering Script Resolver Scripts
 Repository Output It’s still mostly Sling, with the addition of a (scripted?) content aggregation step. Federated services provide more deployment and scaling options. Sandboxed Execution Isolated Content Sandboxed Execution
  • 12. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 12 Sandboxing & IsolationHow?
  • 13. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 13 Sandboxing & Isolation? Scripting and Rendering Sandboxed Execution Content
 Repository Isolated Content Content Aggregator Sandboxed Execution Repository Access Control can work but require a dynamic search path in Sling, see our experiments. Impacts caching, and mapping of incoming to resource paths is needed.Tried and tested. Repository jails look possible with probable impact on Sling internals. Same with multiple SlingRepository services. New and more like a blacklist. Custom, restricted languages are the safest? HTL (Use-API?), Handlebars? Sandboxing Nashorn (JavaScript) looks possible but not ideal, see our experiments. Sandboxing Java is not realistic- IBM canceled multi tenant JVM project for example.
  • 14. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 14 But it’s a VM, right? Oak Libraries Sling Engine JavaVirtual Machine content Oak Libraries Sling Engine JavaVirtual Machine content Oak Libraries Sling Engine JavaVirtual Machine content Perfect isolation! Java classes
 memory space Application
 memory space Java classes
 memory space Application
 memory space Java classes
 memory space Application
 memory space But suboptimal use of resources! (and containers wouldn’t help)
  • 15. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 15 Sandboxing scripting languages? <% var length = 0; if (request.getRequestParameter("file") != null) { var file = null; // store file var reqPara = request.getRequestParameter("file"); var is = reqPara.getInputStream(); file = Packages.java.io.File.createTempFile("posttest", ".txt"); var fout = new Packages.java.io.FileOutputStream(file); var c; while ((c = is.read()) != -1) { fout.write(c); } fout.close(); // read length length = file.length(); } %> OS Resources Infinite Loops Java classes & services Memory
 Usage? Many things need to be limited.
 Whitelist approach is much safer -> custom languages?
 HTL inherently sandboxed, except its Use-objects
  • 16. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 16 Containers? Oak Libraries Sling Engine OS container content Java classes
 memory space Application
 memory space SMALL! Shared Memory Pools, Caches etc. memory Oak Libraries Sling Engine OS container content Java classes
 memory space Application
 memory space SMALL! Oak Libraries Sling Engine OS container content Java classes
 memory space Application
 memory space SMALL! Same problem as multiple JVMs Sharing caches, compiled scripts etc. can be a pragmatic solution.
  • 17. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 17 What do we do?
  • 18. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 18 Hybrid Sling Rendering Farm Annotated Aggregated Content HTTP
 front-end HTTP
 routing Scripting + Rendering Script Resolver scripts Shared Services Custom Code Script Resolver scripts Tenant-Specific Services servletscontent Resource
 Resolver Content Aggregator Oak Libraries Shared Services Sandboxed Execution New
 Component Content-driven routing Isolated
 Content Dynamic Search Path Provides the flexibility of Sling via tenant-specific services and dynamic routing. Uses shared services for the common parts. Allows for billable options depending on the actual routing.
  • 19. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 19 Experimentsbuilding blocks that might be reusable
  • 20. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 20 Resolving new types of scripts Experim ent Script Resolver Client
 GET Request Wrapped
 AGG Request Wrap the request to make it appear as an AGG (*) request and pass that to the Sling ServletResolver. Adapt the return SlingScript to an InputStream to read its text. (*) or any other non-existent HTTP verb. Content
 Repository /apps
 /myapp /AGG.js AGG.js
 script
 text Code at https://github.com/bdelacretaz/sling-adaptto-2017 (ContentBVP.java)
  • 21. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 21 Resolving a SLING-CONTENT script Experim ent Code at https://github.com/bdelacretaz/sling-adaptto-2017 (ContentBVP.java) String getAggregatorScript(SlingHttpServletRequest r) { String result = null; Servlet s = servletResolver.resolveServlet( new ChangeMethodRequestWrapper(r, "SLING-CONTENT")); if(s instanceof SlingScript) { InputStream is = ((SlingScript)s).getScriptResource() .adaptTo(InputStream.class); } if(is != null) { result = IOUtils.toString(is) } } return result; } adaptTo() Bonus Points!
  • 22. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 22 Content Aggregation with Sling Query Experim entvar $ = Packages.org.apache.sling.query.SlingQuery.$ var SearchStrategy = Packages.org.apache.sling.query.api.SearchStrategy var resourceResolver = resource.getResourceResolver() var result = { siblings : $(resource).siblings(), rootChildren : $(resource).parents().last().children(), queryResult : $(resourceResolver) .searchStrategy(SearchStrategy.QUERY) .find("nt:base[title=foo]") } Used in a BindingsValuesProvider? Or in a custom json renderer servlet which runs this script. Inherently sandboxed due to custom language. https://sling.apache.org/documentation/bundles/sling-query.html
  • 23. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 23 Dynamic scripts/servlet search path Experim entif(dynamicServletResolver.canResolve(resource)) { servlet = dynamicServletResolver.resolveServlet(request); } else { …existing resolver code } A fairly simple change to the SlingServletResolver - should evolve into a real extension point if desired, and probably get the request as well. Tested in SLING-4386 - another multitenant experiment which provides tenant-specific scripts but no real isolation. Currently requires disabling the servlet resolution cache.
  • 24. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 24 Nashorn (JavaScript) sandboxing (Java Delight) Experim entNashornSandbox { allow(final Class<?> clazz); injectGlobalVariable(String variableName, Object object); setMaxCPUTime(long limitMsec); Object eval(final String javaScriptCode); allowPrintFunctions(boolean v); allowReadFunctions(boolean v); ...more allow functions // $ARG, $ENV, $EXEC... allowGlobalsObjects(final boolean v); } Uses Nashorn’s ClassFilter to block Java classes Sandboxing rewrites standard methods + user code- > blacklisting, not ideal https://github.com/javadelight/delight-nashorn-sandbox (Java Delight Suite)
  • 25. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 25 CODAwhere to now?
  • 26. Building an Apache Sling Rendering Farm - Bertrand Delacretaz, adaptTo 2017 26 CODA Thank you for attending! I’m Bertrand Delacretaz (@bdelacretaz) In-memory nature of Sling is an important differentiator, in good and bad ways! Hybrid Rendering Farm promising - do you need it? Sandboxing is difficult, whitelisting much preferred, custom languages? Reusable
 experiments?