Scheduling Job Involving both RAM and CPU
OverviewThe question was part of a system design question, where I had to design 2 functions: Schedule a JobCheck if Job is finishedThe criteria for scheduling a job on a rack of machines, was that each job requires a certain amount of CPU & RAM, and each machine has different amount of CPU & RAM. So how do I go about optimally scheduling jobs on it? Multiple jobs could be scheduled on the ...
Read more
JVM Architecture
Reference from JVM Architecture – Understanding JVM Internals OverviewEvery Java developer knows that bytecode will be executed by JRE (Java Runtime Environment). But many doesn’t know the fact that Interpreter is the implementation of Java Virtual Machine (JVM), which analyzes the bytecode, interprets the code and executes it. It is very important as a developer we should know the Architecture ...
Read more
Twitter Design
Problem clarify No one expects you to design a real twitter in 50 minutes. You need to focus on several core features first then dive deep. Interviewer will guide you to specific field to get some property of you. Core features Tweeting Timeline User Home Following Naive solution (Synchronous DB queries)Two Tables - User Table ID Name ….. ID1 Name1 ….. ID2 Name2 ….. ID3 Name3 ….. ...
Read more
How to scale dropbox
What is dropboxScale:10s of millions of users100s of millions of the file syncs per day. Challenges Write volume. ACIDity requirements (Atomicity, Consistency, Isolation, Durability) Example #1: High-level architecturePhase 0:Clients –> The ServerThis is the humble beginning of dropbox Phase 1: (The sever is overloaded)Clients –> The Server –> S3/DB(MySQL) Phase 2: (The server may not e ...
Read more
Shorten url system design
OverviewDesign a url shortening service. like bit.ly. Use case Shortening: given a url -> return a much shorten url. Redirection: take a shorten url -> redirect to the original url. Custom url. High availability of the system. Tasks break down New urls per month: 100M. 1 billion request per month. 10% from shortening and 90% from redirection Request per second: 400 (40: shortens; 360:redire ...
Read more
Http response status code
Reference from MDN Web docs OverviewHTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: informational responses, successful responses, redirects, client errors, and servers errors. Status codes are defined by section 10 of RFC 2616. Information responses100 ContinueThis interim response indicates that everyth ...
Read more
Leetcode 1-10
1. Two Sum🍏🍏🍏 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: 1234Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1]. Solution 1:123456789101112131415class Solution { public ...
Read more
Homebrew Instruction
Homebrew Cask Reference from Homebrew Cask Repository Homebrew Cask extends Homebrew and brings its elegance, simplicity, and speed to the installation and management of GUI macOS applications such as Atom and Google Chrome. Install Java8 shows as below(results may various based on your env property):12345678910111213141516171819202122232425262728293031323334~ brew cask install java8Updating Home ...
Read more
Java FAQ
Why would the ‘final’ keyword ever be useful?final expresses intent. It tells the user of a class, method or variable “This element is not supposed to change, and if you want to change it, you haven’t understood the existing design.” This is important because program architecture would be really, really hard if you had to anticipate that every class and every method you ever write might be changed ...
Read more
How to install Java 8 with Home Brew
Reference from How to install Java 8 with homwbrew Don’t rely on Oracle to install Java properly on your Mac. Use Homebrew. this will install the latest jdk: 1brew cask install java If you want to manage multiple versions of Java on your Mac, consider using jenv. UPDATE: Now that Java 8 is no longer the most current version, if you want java 8 install it this way: 12brew tap caskroom/versionsbre ...
Read more