SlideShare une entreprise Scribd logo
1  sur  26
Thanks to our
AWESOME
sponsors!
ControlFreak’s
Simplist’s
A Minimalist’s Attempt at
Building a Distributed
Application
David Hoerster
About Me
 C# MVP (Since April 2011)
 Sr. Director of Web Solutions at RGP

 Conference Director for Pittsburgh TechFest
 Co-Founder of BrainCredits (braincredits.com)
 Past President of Pittsburgh .NET Users Group and organizer of recent Pittsburgh Code Camps and
other Tech Events
 Twitter - @DavidHoerster
 Blog – http://geekswithblogs.net/DavidHoerster
 Email – david@agileways.com
The Minimalist’s Goals
 Easy setup and install
 Able to deploy almost anywhere (low dependency)

 Contained intent
 Anti-Scavenger Hunt Development

 Convention favored over heavy configuration
 But I have control if needed

 No significant performance hit
 Improvement preferred!

 PhD not required
What Do These Have in Common?

Run from a console
Full featured web app aspects
No need for IIS or installed web server
Jenkins/Solr are JVM; Raven is .NET
My Project

 Have a demo app for using Solr in .NET

Solr

 Works great, but dependent on IIS
 Want to make it more like Solr
 Install anywhere

Client

Nancy
IIS
(.EXE)
(WP)

 Easy to set up and get running

 Very configurable
 Multiple instances running

SQL
Is IIS Evil?

No!
But…
Not everything

requires a hammer
Basic ASP.NET MVC Operation
Controller derives from
Controller

public class QuoteController : Controller {

Specific return types

private readonly QuoteRepository _repo;
public ActionResult Index() {
var quotes = _repo.GetAll();
return View(quotes);
}

}
Helpers that do help…
But what’s the route??
(Have to look in global.asax.)

Web API improves on this with declared return
types (e.g. List<T>) and Web API 2 will have
annotated routes (which takes a lot from Nancy).
What About Bottle (Python)?

Here’s my route
Intuitive method name

@bottle.route('/quote')
def get_all_quotes():
l = solr.query(‘*:*’)
# do some Python projection here to get ll

Tells I’m returning a
template, what the
template is, and what
model(s)

return bottle.template(‘quotes_template', dict(myquotes=ll))
Simplicity over Power

 ASP.NET MVC (and Web API) has a lot of power

 With power comes great responsibility
 Conform
 Sometimes lose intuitiveness of code
 Routes defined elsewhere
 Changing in Web API

 Other configuration throughout app
Get Quotes in Nancy
public class QuoteModule : NancyModule {
private readonly IQuoteRepository _repo;
public QuoteModule(IQuoteRepository repo) {
_repo = repo;
Here’s my route and method

Get["/quote"] = _ =>
{
var quotes = _repo.GetAll();
return View["Index.cshtml", quotes];
};

Returning dictionary with
template and model
}
}
Nancy Differences with ASP.NET MVC
 Simple design to create web methods
 No method names – dictionary of routes and funcs
 Route configuration right in with method definitions
 Good or bad? Hmmm….

 Bare bones distributed service environment
 Low overhead / low ceremony service definitions
 Not heavy on configuration

 However, full async/await support not there…yet
Modules and Routing

 Modules are like Controllers
 Contain routes and route rules

public class QuoteModule : NancyModule {
private readonly QuoteRepository _repo;
public QuoteModule() {
_repo = new QuoteRepository();
Get["/quote"] = _ =>
{
var quotes = _repo.GetAll();
return View["Index.cshtml", quotes];
};

 Essentially all defined in Module constructor
 Watch that business logic doesn’t creep in
 Modules could get unwieldy

}
}
Modules and Routing
In MVC, what’s my action?
Needs to be part of the route, unless default
 What happens here?
 http://localhost/quote/100 (GET)

http://localhost/quote/100 (GET)
http://localhost/quote/delete/100 (DELETE)

 http://localhost/quote/100 (DELETE)

Nancy has dictionaries for actions
Get[“/quote/{id}”] = args => { … }
Delete [“/quote/{id}”] = args => { … }
Modules and Routing

 Nancy’s routing is based on
 Method

Get[“/quote/{id}”] = args => { … }
Delete [“/quote/{id}”] = args => { … }

 Pattern
 Action

 Condition (routes can have conditions)

/quote/getall
/quote/{id?} (optional capture segment)
/quote/(?<id>[a..zA..Z]*) (regex)
Post[“/quote”, x => x.id > 0] = args => {…}
Post[“/quote”, x => x.id < 0] = args => {…}
Finding Modules

 Nancy scans app for NancyModules
 Loads them
 No need to define routes in config or global
 Nancy favors convention over configuration generally
Changing Behavior
 Nancy is a pipeline
 Series of events for each request

Request

 Want forms authentication?
 Add it to the pipeline

Auth

Error
Handler

Custom

Before
Actions

 Want custom error page
 Add it to the pipeline

 Steps can be added at application, module and route level
 Allows fine grain control for distributed app dev

Module
Changing Behavior

 Creating a custom bootstrapper allows for custom behavior at app level

 Before and After Hooks for application and module
 Logging and events

 Page Handlers for page type specific behavior
 Handle custom 404’s

 Static files
 If outside of /Content, need to configure in Bootstrapper

pipelines.BeforeRequest += (ctx) =>
{
Logger.Log("starting…");
Command.Enqueue(new Command());
return null;
};
pipelines.AfterRequest += (ctx) =>
{
Logger.Log("ending request");
};
Authentication

 By default, none

 Somewhat bare bones, but gets the job done

var formsAuthCfg =
new FormsAuthenticationConfiguration()
{
RedirectUrl = "~/login",
UserMapper = container.Resolve<IUserMapper>(),
};

 Configure through Bootstrapper

FormsAuthentication.Enable(pipelines, formsAuthCfg);

 Forms Authentication module is available
 Get it from NuGet
Content Negotiation
 Nancy detects the Accept header on a request
 If applicable, will return data in that form
 Default formats are
 JSON
 XML
 View

Get["/api/quote"] = _ =>
{
return _repo.GetAll()
.Quotes
.ToList();
};

 Also configurable via Bootstrapper
 Gotcha! XML needs to be materialized, not deferred (List<> vs. IEnumerable<>)
Dependency Injection

 By default, TinyIoc is built in

private readonly IQuoteRepository _repo;
public QuoteModule(IQuoteRepository repo)
{
_repo = repo;

 Nancy co-developer’s project

 Works well – rated as average on IoC Benchmark by Daniel Palme
 Able to use IoC of choice
 Configure through Bootstrapper

 Example with Ninject

 Built in IoC allows automatic (magic?) injection of instances into Modules

How did this get here?
Performance (Requests/Second)
NancyFX and IIS 8.5 Requests/Second
160.00
140.00

120.00
100.00
80.00
60.00
40.00
20.00
SU-20-1

SU-100-1

SU-500-1

MU-50-5

NancyFX

IIS 8.5

MU-100-10

MU-500-5

MU-1000-10
Performance (Time/Request)
NancyFX and IIS 8.5 Time (ms)/Request
50.00
45.00
40.00
35.00
30.00
25.00
20.00
15.00
10.00
5.00
SU-20-1

SU-100-1

SU-500-1

MU-50-5
NancyFX

IIS 8.5

MU-100-10

MU-500-5

MU-1000-10
The Minimalist’s Goals - Recap
 Easy setup and install
 Able to deploy almost anywhere (low dependency)
 Contained intent
 Anti-Scavenger Hunt Development

 Convention favored over heavy configuration
 But I have control if needed

 No significant performance hit
 PhD not required
What’s Next?

 Nancy + Katana (OWIN)
 Other ASP.NET components moving to pipeline model
 Be able to plug in SignalR and other pieces into Katana
 Great article in MSDN Magazine about Nancy + Katana + SignalR + WebApi

 Custom view renderers

 Custom pipeline components
Resources
 NancyFx Site: http://nancyfx.org/
 Documentation: https://github.com/NancyFx/Nancy/wiki/Documentation
 Howard Dierking on Nancy and Katana: http://msdn.microsoft.com/enus/magazine/dn451439.aspx
 Dependency Injection Rankings: http://www.palmmedia.de/Blog/2011/8/30/ioccontainer-benchmark-performance-comparison
 Session Code: https://github.com/DavidHoerster/Minimalist.Solr
 Slides: http://www.slideshare.net/dhoerster/a-minimalists-attempt-at-building-adistributed-application

Contenu connexe

Tendances

Kick start your journey as mern stack developer
Kick start your journey as mern stack developerKick start your journey as mern stack developer
Kick start your journey as mern stack developerShrutiPanjwani1
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and FrameworkChandrasekar G
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Jeremy Likness
 
Introduction to MERN Stack
Introduction to MERN StackIntroduction to MERN Stack
Introduction to MERN StackSurya937648
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebChris Canal
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographicInApp
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stackPraveen Gubbala
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page ApplicationKMS Technology
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondSpike Brehm
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceDomingo Suarez Torres
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesAndy_Gaskell
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Nativedvcrn
 
Building Cross Platform Mobile Apps
Building Cross Platform Mobile AppsBuilding Cross Platform Mobile Apps
Building Cross Platform Mobile AppsShailendra Chauhan
 
After the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEANAfter the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEANJeff Fox
 
Web Applications Development with MEAN Stack
Web Applications Development with MEAN StackWeb Applications Development with MEAN Stack
Web Applications Development with MEAN StackShailendra Chauhan
 

Tendances (20)

Kick start your journey as mern stack developer
Kick start your journey as mern stack developerKick start your journey as mern stack developer
Kick start your journey as mern stack developer
 
Mern stack developement
Mern stack developementMern stack developement
Mern stack developement
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and Framework
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
Introduction to MERN Stack
Introduction to MERN StackIntroduction to MERN Stack
Introduction to MERN Stack
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographic
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stack
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page Application
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and Beyond
 
Frontend as a first class citizen
Frontend as a first class citizenFrontend as a first class citizen
Frontend as a first class citizen
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page Interface
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiences
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Codegen2021 blazor mobile
Codegen2021 blazor mobileCodegen2021 blazor mobile
Codegen2021 blazor mobile
 
Angular 2 vs React
Angular 2 vs ReactAngular 2 vs React
Angular 2 vs React
 
Building Cross Platform Mobile Apps
Building Cross Platform Mobile AppsBuilding Cross Platform Mobile Apps
Building Cross Platform Mobile Apps
 
After the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEANAfter the LAMP, it's time to get MEAN
After the LAMP, it's time to get MEAN
 
Web Applications Development with MEAN Stack
Web Applications Development with MEAN StackWeb Applications Development with MEAN Stack
Web Applications Development with MEAN Stack
 

Similaire à A Minimalist’s Attempt at Building a Distributed Application

New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxMuralidharan Deenathayalan
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To MvcVolkan Uzun
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Rodolfo Finochietti
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentationbuildmaster
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Fwdays
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...Carl Brown
 
Working with AngularJS
Working with AngularJSWorking with AngularJS
Working with AngularJSAndré Vala
 
Clean Architecture on Android
Clean Architecture on AndroidClean Architecture on Android
Clean Architecture on AndroidTianming Xu
 

Similaire à A Minimalist’s Attempt at Building a Distributed Application (20)

J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
 
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentation
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
Maciej Treder "Server-side rendering with Angular—be faster and more SEO, CDN...
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
 
Working with AngularJS
Working with AngularJSWorking with AngularJS
Working with AngularJS
 
Practical OData
Practical ODataPractical OData
Practical OData
 
Data access
Data accessData access
Data access
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Clean Architecture on Android
Clean Architecture on AndroidClean Architecture on Android
Clean Architecture on Android
 

Plus de David Hoerster

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?David Hoerster
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetDavid Hoerster
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceDavid Hoerster
 
Freeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureFreeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureDavid Hoerster
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureDavid Hoerster
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRSDavid Hoerster
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherDavid Hoerster
 

Plus de David Hoerster (10)

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Creating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnetCreating scalable message driven solutions akkadotnet
Creating scalable message driven solutions akkadotnet
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
 
Mongo Baseball .NET
Mongo Baseball .NETMongo Baseball .NET
Mongo Baseball .NET
 
Freeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureFreeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS Architecture
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows Azure
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect Together
 

Dernier

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

A Minimalist’s Attempt at Building a Distributed Application

  • 2. ControlFreak’s Simplist’s A Minimalist’s Attempt at Building a Distributed Application David Hoerster
  • 3. About Me  C# MVP (Since April 2011)  Sr. Director of Web Solutions at RGP  Conference Director for Pittsburgh TechFest  Co-Founder of BrainCredits (braincredits.com)  Past President of Pittsburgh .NET Users Group and organizer of recent Pittsburgh Code Camps and other Tech Events  Twitter - @DavidHoerster  Blog – http://geekswithblogs.net/DavidHoerster  Email – david@agileways.com
  • 4. The Minimalist’s Goals  Easy setup and install  Able to deploy almost anywhere (low dependency)  Contained intent  Anti-Scavenger Hunt Development  Convention favored over heavy configuration  But I have control if needed  No significant performance hit  Improvement preferred!  PhD not required
  • 5. What Do These Have in Common? Run from a console Full featured web app aspects No need for IIS or installed web server Jenkins/Solr are JVM; Raven is .NET
  • 6. My Project  Have a demo app for using Solr in .NET Solr  Works great, but dependent on IIS  Want to make it more like Solr  Install anywhere Client Nancy IIS (.EXE) (WP)  Easy to set up and get running  Very configurable  Multiple instances running SQL
  • 7. Is IIS Evil? No! But… Not everything requires a hammer
  • 8. Basic ASP.NET MVC Operation Controller derives from Controller public class QuoteController : Controller { Specific return types private readonly QuoteRepository _repo; public ActionResult Index() { var quotes = _repo.GetAll(); return View(quotes); } } Helpers that do help… But what’s the route?? (Have to look in global.asax.) Web API improves on this with declared return types (e.g. List<T>) and Web API 2 will have annotated routes (which takes a lot from Nancy).
  • 9. What About Bottle (Python)? Here’s my route Intuitive method name @bottle.route('/quote') def get_all_quotes(): l = solr.query(‘*:*’) # do some Python projection here to get ll Tells I’m returning a template, what the template is, and what model(s) return bottle.template(‘quotes_template', dict(myquotes=ll))
  • 10. Simplicity over Power  ASP.NET MVC (and Web API) has a lot of power  With power comes great responsibility  Conform  Sometimes lose intuitiveness of code  Routes defined elsewhere  Changing in Web API  Other configuration throughout app
  • 11. Get Quotes in Nancy public class QuoteModule : NancyModule { private readonly IQuoteRepository _repo; public QuoteModule(IQuoteRepository repo) { _repo = repo; Here’s my route and method Get["/quote"] = _ => { var quotes = _repo.GetAll(); return View["Index.cshtml", quotes]; }; Returning dictionary with template and model } }
  • 12. Nancy Differences with ASP.NET MVC  Simple design to create web methods  No method names – dictionary of routes and funcs  Route configuration right in with method definitions  Good or bad? Hmmm….  Bare bones distributed service environment  Low overhead / low ceremony service definitions  Not heavy on configuration  However, full async/await support not there…yet
  • 13. Modules and Routing  Modules are like Controllers  Contain routes and route rules public class QuoteModule : NancyModule { private readonly QuoteRepository _repo; public QuoteModule() { _repo = new QuoteRepository(); Get["/quote"] = _ => { var quotes = _repo.GetAll(); return View["Index.cshtml", quotes]; };  Essentially all defined in Module constructor  Watch that business logic doesn’t creep in  Modules could get unwieldy } }
  • 14. Modules and Routing In MVC, what’s my action? Needs to be part of the route, unless default  What happens here?  http://localhost/quote/100 (GET) http://localhost/quote/100 (GET) http://localhost/quote/delete/100 (DELETE)  http://localhost/quote/100 (DELETE) Nancy has dictionaries for actions Get[“/quote/{id}”] = args => { … } Delete [“/quote/{id}”] = args => { … }
  • 15. Modules and Routing  Nancy’s routing is based on  Method Get[“/quote/{id}”] = args => { … } Delete [“/quote/{id}”] = args => { … }  Pattern  Action  Condition (routes can have conditions) /quote/getall /quote/{id?} (optional capture segment) /quote/(?<id>[a..zA..Z]*) (regex) Post[“/quote”, x => x.id > 0] = args => {…} Post[“/quote”, x => x.id < 0] = args => {…}
  • 16. Finding Modules  Nancy scans app for NancyModules  Loads them  No need to define routes in config or global  Nancy favors convention over configuration generally
  • 17. Changing Behavior  Nancy is a pipeline  Series of events for each request Request  Want forms authentication?  Add it to the pipeline Auth Error Handler Custom Before Actions  Want custom error page  Add it to the pipeline  Steps can be added at application, module and route level  Allows fine grain control for distributed app dev Module
  • 18. Changing Behavior  Creating a custom bootstrapper allows for custom behavior at app level  Before and After Hooks for application and module  Logging and events  Page Handlers for page type specific behavior  Handle custom 404’s  Static files  If outside of /Content, need to configure in Bootstrapper pipelines.BeforeRequest += (ctx) => { Logger.Log("starting…"); Command.Enqueue(new Command()); return null; }; pipelines.AfterRequest += (ctx) => { Logger.Log("ending request"); };
  • 19. Authentication  By default, none  Somewhat bare bones, but gets the job done var formsAuthCfg = new FormsAuthenticationConfiguration() { RedirectUrl = "~/login", UserMapper = container.Resolve<IUserMapper>(), };  Configure through Bootstrapper FormsAuthentication.Enable(pipelines, formsAuthCfg);  Forms Authentication module is available  Get it from NuGet
  • 20. Content Negotiation  Nancy detects the Accept header on a request  If applicable, will return data in that form  Default formats are  JSON  XML  View Get["/api/quote"] = _ => { return _repo.GetAll() .Quotes .ToList(); };  Also configurable via Bootstrapper  Gotcha! XML needs to be materialized, not deferred (List<> vs. IEnumerable<>)
  • 21. Dependency Injection  By default, TinyIoc is built in private readonly IQuoteRepository _repo; public QuoteModule(IQuoteRepository repo) { _repo = repo;  Nancy co-developer’s project  Works well – rated as average on IoC Benchmark by Daniel Palme  Able to use IoC of choice  Configure through Bootstrapper  Example with Ninject  Built in IoC allows automatic (magic?) injection of instances into Modules How did this get here?
  • 22. Performance (Requests/Second) NancyFX and IIS 8.5 Requests/Second 160.00 140.00 120.00 100.00 80.00 60.00 40.00 20.00 SU-20-1 SU-100-1 SU-500-1 MU-50-5 NancyFX IIS 8.5 MU-100-10 MU-500-5 MU-1000-10
  • 23. Performance (Time/Request) NancyFX and IIS 8.5 Time (ms)/Request 50.00 45.00 40.00 35.00 30.00 25.00 20.00 15.00 10.00 5.00 SU-20-1 SU-100-1 SU-500-1 MU-50-5 NancyFX IIS 8.5 MU-100-10 MU-500-5 MU-1000-10
  • 24. The Minimalist’s Goals - Recap  Easy setup and install  Able to deploy almost anywhere (low dependency)  Contained intent  Anti-Scavenger Hunt Development  Convention favored over heavy configuration  But I have control if needed  No significant performance hit  PhD not required
  • 25. What’s Next?  Nancy + Katana (OWIN)  Other ASP.NET components moving to pipeline model  Be able to plug in SignalR and other pieces into Katana  Great article in MSDN Magazine about Nancy + Katana + SignalR + WebApi  Custom view renderers  Custom pipeline components
  • 26. Resources  NancyFx Site: http://nancyfx.org/  Documentation: https://github.com/NancyFx/Nancy/wiki/Documentation  Howard Dierking on Nancy and Katana: http://msdn.microsoft.com/enus/magazine/dn451439.aspx  Dependency Injection Rankings: http://www.palmmedia.de/Blog/2011/8/30/ioccontainer-benchmark-performance-comparison  Session Code: https://github.com/DavidHoerster/Minimalist.Solr  Slides: http://www.slideshare.net/dhoerster/a-minimalists-attempt-at-building-adistributed-application