You are previewing JavaScript at Scale.
O'Reilly logo
JavaScript at Scale

Book Description

Build enduring JavaScript applications with scaling insights from the front-line of JavaScript development

In Detail

Filled with real-world JavaScript scaling scenarios, and code-first examples, JavaScript at Scale is your guide to building applications that last and will show you how to deal with scalability from a number of perspectives: addressability, testability, and component composition. By understanding the fundamentals of scaling issues, you'll be able to use that knowledge to tackle even the most difficult of situations.

The book begins by defining "scale" from a JavaScript point of view, and further dives into the influencers of scale, as well as scalable component composition and communication. Large-scale architectures need the ability to scale down, and recover from failing components, as well as scale up and manage new features or a large user base. From here, you can build applications that scale using any set of JavaScript tools.

What You Will Learn

  • Identify and evaluate the external scaling influencers of your application

  • Build out component composition in large-scale JavaScript applications

  • Discover the techniques for inter-component communication that scale

  • Customize and configure components to meet scaling demands

  • Ensure a highly-performant user experience, despite the size and complexity of your application

  • Create a portable and testable application that's not constrained to one environment

  • Make architectural trade-offs by removing or refactoring components

  • Design components that fail in a scalable way

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. JavaScript at Scale
      1. Table of Contents
      2. JavaScript at Scale
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Scale from a JavaScript Perspective
        1. Scaling influencers
          1. The need for scale
          2. Growing user base
          3. Building new features
          4. Hiring more developers
        2. Architectural perspectives
        3. The browser is a unique environment
          1. Component design
          2. Component communication
          3. Load time
          4. Responsiveness
          5. Addressability
          6. Configurability
        4. Making architectural trade-offs
          1. Defining your constants
          2. Performance for ease of development
          3. Configurability for performance
          4. Performance for substitutability
          5. Ease of development for addressability
          6. Maintainability for performance
          7. Less features for maintainability
          8. Leveraging frameworks
        5. Frameworks versus libraries
          1. Implementing patterns consistently
          2. Performance is built in
          3. Leverage community wisdom
          4. Frameworks don't scale out-of-the-box
        6. Summary
      9. 2. Influencers of Scale
        1. Scaling users
          1. License fees
          2. Subscription fees
          3. Consumption fees
          4. Ad-supported
          5. Open source
          6. Communicating users
          7. Support mechanisms
          8. Feedback mechanisms
          9. Notifying users
          10. User metrics
          11. Scaling users example
        2. Scaling features
          1. Application value
          2. Killer features versus features that kill
          3. Data-driven features
          4. Competing with other products
          5. Modifying existing features
          6. Supporting user groups and roles
          7. Introducing new services
          8. Consuming real-time data
          9. Scaling features example
        3. Scaling development
          1. Finding development resources
          2. Development responsibilities
          3. Too many resources
          4. Scaling development example
        4. Influencer checklist
          1. User checklist
            1. What's the business model of our software?
            2. Does our application have different user roles?
            3. Do our users communicate with each other using our software?
            4. How do we support our application?
            5. How do we collect feedback from users?
            6. How do we notify users with relevant information?
            7. What type of user metrics should we collect?
          2. Feature checklist
            1. What's the core value proposition of our software?
            2. How do we determine the feasibility of a feature?
            3. Can we make informed decisions about our features?
            4. Who's our competition?
            5. How do we make what we have better?
            6. How do we integrate user management into our features?
            7. Are our features tightly coupled to backend services?
            8. How does the frontend stay synchronized with backend data?
          3. Developer checklist
            1. How do we find the right development resources?
            2. How do we allocate development responsibilities?
            3. Can we avoid hiring too many resources?
        5. Summary
      10. 3. Component Composition
        1. Generic component types
          1. Modules
          2. Routers
          3. Models/Collections
          4. Controllers/Views
          5. Templates
          6. Application-specific components
        2. Extending generic components
          1. Identifying common data and functionality
          2. Extending router components
          3. Extending models/collections
          4. Extending controllers/views
        3. Mapping features to components
          1. Generic features
          2. Specific features
        4. Decomposing components
          1. Maintaining and debugging components
          2. Re-factoring complex components
        5. Pluggable business logic
          1. Extending versus configuring
          2. Stateless business logic
        6. Organizing component code
        7. Summary
      11. 4. Component Communication and Responsibilities
        1. Communication models
          1. Message-passing models
          2. Event models
        2. Communication data schema
          1. Naming conventions
          2. Data format
          3. Common data
        3. Traceable component communication
          1. Subscribing to events
          2. Globally-logging events
          3. Event lifecycle
        4. Communication overhead
          1. Event frequency
          2. Callback execution time
          3. Callback complexity
        5. Areas of communication responsibility
          1. Backend API
          2. Web socket updates
          3. DOM updates
        6. Loosely-coupled communication
          1. Substituting components
          2. Handling unexpected events
        7. Component layers
          1. Event flow direction
          2. Mapping to developer responsibilities
          3. Mentally mapping the code
        8. Summary
      12. 5. Addressability and Navigation
        1. Approaches to routing
          1. Hash URIs
          2. Traditional URIs
        2. How routers work
          1. Router responsibilities
          2. Router events
        3. URI parts and patterns
          1. Encoding information
          2. Designing URIs
        4. Mapping resources to URIs
          1. Building URIs manually
          2. Automating resource URIs
        5. Triggering routes
          1. User actions
          2. Redirecting users
        6. Router configuration
          1. Static route declarations
          2. Registration events
          3. Deactivating routes
        7. Troubleshooting routers
          1. Conflicting routes
          2. Logging initial configuration
          3. Logging route events
          4. Handling invalid resource states
        8. Summary
      13. 6. User Preferences and Defaults
        1. Preference types
          1. Locales
          2. Behavior
          3. Appearance
        2. Supporting locales
          1. Deciding on locales to support
          2. Maintaining locales
        3. Setting the locale
          1. Choosing locales
          2. Storing locale preferences
          3. Locales in URIs
        4. Generic component configuration
          1. Deciding on configuration values
          2. Stored and hard-coded default values
          3. Backend implications
          4. Loading configuration values
        5. Configuring behavior
          1. Enabling and disabling components
          2. Changing quantities
          3. Changing order
          4. Configuring notifications
          5. Inline options
        6. Changing the look and feel
          1. Theme tools
          2. Selecting a theme
          3. Individual style preferences
        7. Performance implications
          1. Configurable locale performance
          2. Configurable behavior performance
          3. Configurable theme performance
        8. Summary
      14. 7. Load Time and Responsiveness
        1. Component artifacts
          1. Component dependencies
          2. Building components
        2. Loading components
          1. Loading modules
          2. Lazy module loading
          3. Module load latency
        3. Communication bottlenecks
          1. Reducing indirection
          2. Profiling code
        4. Component optimization
          1. Components that maintain state
          2. Dealing with side-effects
          3. DOM rendering techniques
        5. API data
          1. Load latency
          2. Working with large data sets
        6. Optimizing components at runtime
        7. Summary
      15. 8. Portability and Testing
        1. Decoupling the backend
          1. Mocking the backend API
          2. Frontend entry points
          3. Mocking tools
          4. Generating mock data sets
          5. Performing actions
        2. Feature design process
          1. Designing the API
          2. Implementing the mock
          3. Implementing the feature
          4. Reconciling mock data with API data
        3. Unit testing tools
          1. Tools built into frameworks
          2. Standalone unit testing tools
          3. Toolchains and automation
        4. Testing mock scenarios
          1. Mock APIs and test fixtures
          2. Scenario generation tools
        5. End-to-end tests and continuous integration
        6. Summary
      16. 9. Scaling Down
        1. Scaling constraints
          1. JavaScript artifact size
          2. Network bandwidth
          3. Memory consumption
          4. CPU consumption
          5. Backend capabilities
        2. Conflicting features
          1. Overlapping functionality
          2. Irrelevant features
          3. Customer demand
        3. Design failures
          1. Unnecessary components
          2. Inefficient data processing
          3. Excessively creative markup
        4. Application composition
          1. Feature enablement
          2. New feature impact
          3. Essential libraries
        5. Summary
      17. 10. Coping with Failure
        1. Failing fast
          1. Using quality constraints
          2. Providing meaningful feedback
          3. When we can't fail fast...
        2. Fault tolerance
          1. Classifying critical behavior
          2. Detecting and containing errant behavior
          3. Disabling defective components
          4. Gracefully degrading functionality
        3. Failure recovery
          1. Retrying failed operations
          2. Restarting components
          3. Manual user intervention
          4. When we can't recover from failures...
        4. Performance and complexity
          1. Exception handling
          2. State checking
          3. Notifying other components
        5. Logging and debugging
          1. Meaningful error logs
          2. Warning about potential failures
          3. Informing and instructing users
        6. Improving the architecture
          1. Documenting failure scenarios
          2. Improving component classification
          3. Complexity promotes failure
        7. Summary
      18. Index