Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

"With fejo.dk we want to provide the best experience brokering cottage homes in Denmark."

Slide 11

Slide 11 text

• Company started in 1993 • Small team (2 developers*, ~20 in total) • Working business model • Complex business logic and data Context *2015

Slide 12

Slide 12 text

Goals • Responsive Design • Re-enable team to feasible add new features • Attract new developers

Slide 13

Slide 13 text

Contraints • Existing system brings in the money • Minimise Risk • Limited amount of resources

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

–Old Klingon Proverb “Just extract a µ-Service for each of the identified bounded context and you're golden.”

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

SPOILER ALERT! !

Slide 18

Slide 18 text

We built a new Monolith

Slide 19

Slide 19 text

We built a new Monolith with Ruby on Rails…

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

…and are not finished yet !

Slide 22

Slide 22 text

Monolith µ-Services

Slide 23

Slide 23 text

Except, it's not!

Slide 24

Slide 24 text

THE FOLLOWING SLIDES HAVE BEEN APPROVED FOR ALL AUDIENCES BY THE BOARD OF BUZZWORDERY, INC. THE VIEWS ADVERTISED HAVE BEEN RATED ® SUBJECTIVE S www.yakshed.org CEOS REQUIRE ACCOMPANYING CERTIFIED DEVOP WHAT YOU ARE ABOUT TO SEE MAY CONTAIN SUBJECTIVE VIEWS OF THE SPEAKERS

Slide 25

Slide 25 text

#1

Slide 26

Slide 26 text

TEAM SIZE

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Business Driven Development

Slide 30

Slide 30 text

Small company Small business needs ≭

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Modularisation /ˌmɒdjʊlərʌɪˈzeɪʃn/

Slide 34

Slide 34 text

"That's not the motivation you're looking for."

Slide 35

Slide 35 text

–Wikipedia “Modular programming is a software design technique that emphasises separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.”

Slide 36

Slide 36 text

Design decoupled components Design for Replacement Separation of Concern Systemic enforcement of modular structure

Slide 37

Slide 37 text

Systemic enforcement of modular structure

Slide 38

Slide 38 text

But…

Slide 39

Slide 39 text

• Requires more discipline • Supported by • Strict code reviews • Tests / Linter / Structure* • Imagine natural vs artificial border *https://medium.com/@dan_manges/the-modular-monolith-rails-architecture-fb1023826fc4

Slide 40

Slide 40 text

Separation of Concern

Slide 41

Slide 41 text

Legacy Encapsulation

Slide 42

Slide 42 text

• Dedicated areas in both Code and Data • Extend legacy system with "modern" API • Encapsulate and transform data between systems • Emulate the interface of the new system

Slide 43

Slide 43 text

Importer System

Slide 44

Slide 44 text

• Data includes • Facilities • Description • Images • Prices and availabilities • From over 40 different partner

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Retrieval Aggregation Mapping Enrichment Persistence Queries DB Saves to DB Queries DB Saves to DB Exceptions go here

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Retrieval Aggregation Mapping Enrichment Persistence

Slide 51

Slide 51 text

Retrieval Aggregation Mapping Enrichment Persistence Explicit Process Model

Slide 52

Slide 52 text

Retrieval Aggregation Mapping Enrichment Persistence Explicit interfaces & data format Exceptions go here

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Design for Replacement

Slide 55

Slide 55 text

" in #

Slide 56

Slide 56 text

Legacy Encapsulation

Slide 57

Slide 57 text

Importer System • Easily remove partner who quit • Easily change specific importer logic • Remove temporary exceptions

Slide 58

Slide 58 text

Decoupled Components

Slide 59

Slide 59 text

Importer System

Slide 60

Slide 60 text

module ImageServer !class App < Sinatra::!Base configure :production do disable :show_exceptions end not_found do respond_with_404 end set :public_folder, File.join(File.dirname(__FILE__), '..', '..', 'public') set :available_image_sizes, !{ !!:mini => [106, 71], !:klein => [138, 92], !:mittel => [145, 108], !:mail => [175, 117], !:gross => [645, 430], !:grundriss => [617, nil], !:grundriss_mit_legende => [415, nil] !} before do expires !86400, :public # expire after one day end get '/' do File.read(File.join(settings.public_folder, 'index.html')) end !get %r{/hausbilder/(.*)_(#{settings.available_image_sizes.keys.join("|")})\.!(\w+)} do image_path = params[:captures][0] requested_size = params[:captures][1].to_sym image_extension = params[:captures][2] if settings.available_image_sizes.keys.include?(requested_size) original_filename = File.join(settings.public_folder, 'hausbilder', "#{!image_path}.#{image_extension}") if File.!exists?(original_filename) thumbnail = MiniMagick::Image.open(original_filename) width, height = settings.available_image_sizes[requested_size] unless image_extension.downcase.include?(!"svg") !!if requested_size == :grundriss_mit_legende || requested_size == :!grundriss thumbnail.combine_options do |c| c.resize "#{width}x>" end elsif requested_size != :gross || is_landscape?(thumbnail) thumbnail.combine_options do |c| c.resize "#{width}x#{height}^" c.gravity !"center" c.extent "#{width}x#{height}" end else thumbnail.combine_options do |c| c.resize "#{width}x#{height}" c.gravity !"center" c.bordercolor !"#ffffff" c.border "#{!width/2}x#{!width/2}" c.extent "#{width}x#{height}" end end end content_type thumbnail.mime_type status 200 expires !!86400*365, :public # expire after one week thumbnail.to_blob else respond_with_404 end end end get !"/photos/*" do |image_path| original_filename = File.join(settings.public_folder, 'dropbox_sync', !image_path.downcase) requested_width = request[!"w"].to_i if original_filename != photo_lookup(original_filename) if requested_width > 0 image = MiniMagick::Image.open(original_filename) image.combine_options do |option| option.resize "#{requested_width}x>" end content_type image.mime_type status 200 image.to_blob else send_file original_filename end else respond_with_404 end end helpers do def !is_landscape?(image) image[!"width"] >= image[!"height"] end def respond_with_404 content_type !"image/png" status 404 expires 600, :public_folder # expire after 10 Minutes File.read(File.join(settings.public_folder, 'images', '!missing_house_picture.png')) end def photo_lookup(filename) !if File.!exists?(filename) !return filename elsif File.extname(filename) == !".jpg" filename_jpeg = filename.gsub(/\.jpg$/, !".jpeg") return filename_jpeg if File.!exists?(filename_jpeg) end end end end end Image Server

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

We ended up with a quite modular system

Slide 63

Slide 63 text

Best Tool for the Job

Slide 64

Slide 64 text

Polyglot Programming and Persistence • Acknowledge different requirements within the application • We're building a web application ! • But: Harder to share knowledge

Slide 65

Slide 65 text

SELECT calculate_house_price(houses.price_data, $PEOPLE, $PETS) AS price FROM houses WHERE houses.id = $HOUSE_ID Stored Function Call

Slide 66

Slide 66 text

Modern Infrastructure requires µ-Services

Slide 67

Slide 67 text

Modern Infrastructure • Modern (Dev)Ops tooling • Automated infrastructure • Deployment Monolith • Still using services (Workers, Image Server)

Slide 68

Slide 68 text

Checklist Team size Business driven development Modularisation Best tool for the job

Slide 69

Slide 69 text

Outlook & Remarks

Slide 70

Slide 70 text

You can still deploy smallish services in a Monolith

Slide 71

Slide 71 text

The Modular Deployment Monolith

Slide 72

Slide 72 text

“…you shouldn't start a new project with µ-services, even if you're sure your application will be big enough to make it worthwhile.” Monolith First –Old Vulcan Proverb (by Martin Fowler) $

Slide 73

Slide 73 text

Future steps • Search & Scoring • Booking Process • Remaining parts of Import Process

Slide 74

Slide 74 text

Sum it up • Deliver business value with new system • Operate within reasonable risk for company • Apply modern infrastructure practises • Don't neglect your frontend

Slide 75

Slide 75 text

Aside: Frontend Architecture

Slide 76

Slide 76 text

$ tree app/components/house_search_button app/components/house_search_button ├── _house_search_button.html.haml ├── _house_search_button.scss ├── house_search_button.de.yml └── house_search_button.js

30.485 Häuser anzeigen

Slide 77

Slide 77 text

• > 150 components • Explicit styling for each component • Usage of Custom Elements to isolate JavaScript • Events to communicate between components • ROCA style to reduce dependency on JavaScript

Slide 78

Slide 78 text

Thanks! Questions? Dirk Breuer (@railsbros_dirk) – Sebastian Cohnen (@tisba) PS: Find us at the StormForger booth!