Java

java

byte 1

short 2

char 2

int 4

long 8

float 4

double 8

 

java

Java Collection Map Collection List Set

List

ArrayList vector LinkedList

 

ArrayList

 

ArrayList ArrrayList

10 11 1.5

( 1.5 )

 

vector , , ,JDK1.0 ,Vector ArrayList ,

 

LinkedList

 

Set

HashCode

equals true false

HashSet LinkedHashSet TreeSet

 

HashSet null

 

HashSet

HashSet HashCode

equals true

false (jdk1.8) 8

HashSet HashMap, HashSet HashMap key

HashMap key Set

 

LinkedHashSet HashSet HashSet ,

hashCode

LinkedHashMap

 

TreeSet TreeSet

TreeMap TreeSet Comparable compareTo()

Comparator

TreeSet

 

Map

Map

Map (key,value) Map key key set

Map key hashCode equals Map value

value Collection Map value equals

Map Entry.Entry key

Entry HashMap LinkedHashMap TreeMap HashTable.

HashMap

                1. + + (jdk1.8)

                2. Node

                3.Node key value

                4. key hashCode Node

                5. , null

HashMap

HashMap (k1,v1), k1 hashCode

(k1,v1) , (k2,v2), k1 equals k2

true v1 v2, false (k1,v1) ,

8

HashMap new HashMap() : 16 0.75

12 2

LinkedHashMap HashMap HashMap .

 

TreeMap Key value

HashTable , null map key value value

 

 

page

request HTTP

session HTTP

application

 

request     Request

response   Page

pageContext Page

session Session

application Application

out Page

config Page

page Page

exception page

 

jsp servlet

1.jsp Servlet.(JSP Servlet JVM java

JSP ,Web JSP JVM java )

2.jsp ,servlet .

3.Servlet Jsp HttpServletRequest

HttpServletResponse HttpServlet .

Jsp Servlet Jsp Jsp Java Jsp

Servlet Java Service

 

servlet

1.

2.

3.

4.

( , web.xml Servlet servlet )

(init() ) (service(),doGet(),doPost()) ( destory())

service():

doGet() doPost(). service() , doGet(),doPost().

service . doGet doPost .

service() doGet() .

 

cookie session

1 cookie session

2 cookie cookie cookie session

3 session cookie

4 cookie 4K 20 cookie

5 session cookie

 

 

Single

class Single{

       private Single(){}

       private static Single s=new Single();

       public static Single getInstance()

       {

             return  s;

       }

}

class Single{//Single getInstance

       private Single(){}

       private static Single s=null;

       public static synchronize Single getInstance()

       {

             if(s==null){

                s=new single();

             }

             return  s;

       }

}

 

java

servlet servlet

action

action

action

IOC bean service

 

# $

#{} ${}

#{} mapper sql ?

${} mapper sql

${} value @Param

${} sql

 

SQL

SQL SQL

' or 1=1', SQL

 select count(1) from tab where user=userinput and pass='' or 1=1;

  1=1 SQL

count 1 userinput

SQL SQL

 

&& & | ||

& &&

& && true

false & &&

| ||

| || false

true | ||

 

final finally finalize

 final , , , , , ,finally ,

;finalize

 

int Integer

1 Integer int int java

2 Integer int

3 Integer new Integer int

4 Integer null int 0

 

equals ==

== == ==

( )

 

equals equals Object equals

euqlas ( )

 

StringBuff StringBuilder String

String String String

StringBuffer

StringBuilder StringBuffer

 

Override Overload

1. Override   

1   

2   

3

4 final  

5 private

 

2.Overload   

1

fun(int, float) fun(int, int)  

2   

3   

4

5

 

1

2

3

4

5

6

7

8

9

10

 

.

1.

2. OS

 

.

1.

2.

 

.

 

Spring Bean

JDK JRE JVM ?

JDK Java = JRE Java + Javac

JRE Java = JVM Java + Java SE

 

?

( )

 

4 ?

              

 

   public              

 

   protect             

 

   default              

 

   private               

 

System.Object

 

throw throws

throw

throws

throw throws

throw throws

 

PreparedStatement Statement ?

statement SQL SQL PreparedStatement

SQL PreparedStatement setXXX

 

Statement SQL -

PreparedStatement PreparedStatement

 

PreparedStatement SQL

Statement SQL PreparedStatement

 

doGet() doPost() ?

get ?name=""&id="" 2kb

post Post

doGet

doPOST

 

null undefind ?

undefined null

Error Exception ?

Error

 

Exception

 

?

1.

2.

3.

4. select

IO IO

IO IO

 

ACID ?

1) (Atomic)

2) (Consistent)

3) (Isolated)

4) (Durable)

 

 

 

 

A B

: A row1, B , A row1, ,

update

A row1 B A row1 row2 insert

 

sleep wait ?

sleep() ,wait() .   

sleep , interreput() ;

wait() notify() .

 

sleep wait

  1 Thread Object

  2 sleep wait

  3 wait notify notifyAll sleep

 

?

1 (New)

2 (Runnable) start()

CPU CPU

3 (Running) CPU

4 (Blocked) CPU

 

http https ?

1 https ca

2 http https ssl

3 http https 80 443

4 http HTTPS SSL+HTTP http

 

?

NullPointerException -

ClassCastException -

IllegalArgumentException -

ArithmeticException -

ArrayStoreException -

IndexOutOfBoundsException -

NegativeArraySizeException -

NumberFormatException -

SecurityException -

UnsupportedOperationException -

 

BIO NIO ?

/

BIO IO,

 

NIO IO buffer (chanel) io ,

-> ->

 

       int[] arr={6,3,8,2,9,1};

System.out.println(" ");

for(int num:arr){

System.out.print(num+" ");

}

for(int i=0;i<arr.length-1;i++){//

for(int j=0;j<arr.length-1-i;j++){//

if(arr[j]>arr[j+1]){

int temp=arr[j];

arr[j]=arr[j+1];

arr[j+1]=temp;

}

}

}

System.out.println();

System.out.println(" ");

  for(int num:arr){

  System.out.print(num+" ");

  }

 

1 Employee Comparable

2 Comparable compareTo()

3 compareTo()

public class Employee implements Comparable{

 

     public int compareTo(Object o) {

        if (o instanceof Employee) {

            Employee e = (Employee) o;

            return this.name.compareTo(e.name);//name

        }

        return 0;

    }

}

 

1. Compartor TreeSet

2. compare

3.

4.

TreeSet set = new TreeSet(new Comparator() {

@Override

public int compare(Object o1, Object o2) {

   if(o1 instanceof Student && o2 instanceof Student) {

      Student s1 = (Student)o1;

      Student s2 = (Student)o2;

      int s = s1.getAge() - s2.getAge();

      if(s == 0) {

         return s1.getName().compareTo(s2.getName());

      }

      return s;

   }

   return 0;

}

});

set.add(new Student("aaa", 18));

set.add(new Student("bbb", 8));

set.add(new Student("fff", 38));

set.add(new Student("ccc", 28));

System.out.println(set);

 

hashCode() equals()

 

?

for(int i=1,i<list.size(),i++){

    System.out.println(list.get(i));

}

 

foreach for

for(String string:list){

    System.out.println(string);

}

 

List<String> list=new ArrayList<>();

list.add("abc");

list.add("ghi");

for(Iterator<String> it=list.iterator();it.hasNext();){

      System.out.println(it.next());

}

 

SpringMVC

1 SpringMVC DispatcherServlet
2 DispatcherServlet URL URI( ) URI
HandlerMapping Handler Handler Handler
HandlerExecutionChain DispatcherServlet
3 Handler, HandlerAdapter Handler, Handler
4 Handler(Controller)
5 Handler DispatcherServlet ModelAndView
6 ModelAndView ViewResolver( ) view
7 model response
8

url uri
URI URL URN URN URL URN
URL


@Component @Component spring bean
@Repository Dao ( @Component)
@Service ( @Component)
@Controller ( @Component)


@RequestMapping
@RequestParam
@PathViriable
@ResponseBody json xml
@CookieValue Cookie

 

 

Spring IOC DI AOP

IOC
mm qq ip iq

IOC IoC


mm

spring spring
spring
spring spring
spring

DI
IoC
IoC
IoC

IoC DI DI( ) IOC


Spring AOP AOP
AOP AOP

Spring AOP JDK CGLIB JDK
JDK InvocationHandler Proxy
Spring AOP CGLIB CGLIB Code Generation
Library CGLIB
final CGLIB

AOP Spring AOP annotation xml
spring
@Transactional

 

MyBatis

1 mybatis java jdbc
JDBC
2 mybatis xml statement java statement
sql sql mybatis sql java
3 MyBatis SQL MyBatis JDBC
MyBatis XML Java POJO
4 /
5 Spring
6 MyBatis SQL XML sql SQL
7 ORM
8 SQL

 

SpringBoot

Springboot spring
properties yml
spring main
Springboot Tomcat war
maven

1: Therad 2 Runnable 3 Callable 4
Thread run
class A extends Thread{
public void run(){
for(int i=1;i<=100;i++){
System.out.println("-----------------"+i);
}
}
}
A a = new A();
a.start();

Runnable run
class B implements Runnable{
public void run(){
for(int i=1;i<=100;i++){
System.out.println("-----------------"+i);
}
}
}
B b = new B();
Thread t = new Thread(b);
t.start();
Callable
class A implements Callable<String>{
public String call() throws Exception{
//...
}
}
FutureTask<String> ft = new FutureTask<>(new A());
new Thread(ft).start();

ExcutorService es = Executors.newFixedThreadPool(10);
es.submit(new Runnable(){//});
es.submit(new Runnable(){//});
...
es.shutdown();

Runnable Callable
Callable Runnable
Callable Runnable
Callable call Runnable
Runnable Thread
Runnable
Runnable

 

Java

Bootstrap C++
Extension Java
AppClassLoader Java



ClassNotFoundException

jvm GC tomcat

                                                                                         

CPU I/O  web SQL 

web 

weblogic  JDBC

windows UNIX Linux

                                                                                     

oracle  DBA

CPU I/O       

 

 

^_^

     
--- --- --- web --- SQL

   

tomcat
JVM
JRE



Tomcat

JVM
-Xms 1/64
-Xmx , 1/4
-XX:+PrintGCDetails GC
Tomcat

 

:








1
2

soa
SOA

soa
SOA

:




tomcat Redis Zookeeper








10 1 10
10
( Hadoop Map/Reduce
10 10 10
1 10 1

:

1





Sql



2

HTML   freemaker

ActiveMQ

3
Nginx
Lvs


:



, , , or














1
Storm
Load IO

2



>

:

1.



1 HTTP

IP HTTP Location
302 Location URL



URL ( )

2 DNS
IP
DNS
IP IP IP
IP DNS IP

DNS

IP HTTP
Location
(RR)
IP

DNS
DNS

DNS IP DNS
DNS DNS
DNS

3




1.
2. HTTP

3. DNS

4. HTTP DNS



1.

2.

3.
session Session
Session
1 IP IP

2 Cookie ID Cookie

4 IP
1. NAT NAT
2.
3.VS/TUN
IP
500M
1G 1G

5
linux

linux bonding mod=0~6 -

sql

a,
NOTNULL
b, JOIN (Sub-Queries)
c, (UNION)
d,
a)
BEGIN COMMIT SQL ROLLBACK
BEGIN
b)

e,
f,
g,
h,
i
j
k
l
m
o


OR like %

Redis

redis key-value
redis redis
redis Redis
Value 5 string hash list set zset sorted set ;

String key value
Hash key string value map key-value
List LPUSH RPUSH
Set
value null hashmap
zset set double score

Memcache redis
redis k/v list set zset hash
memcache k/v key value string
memcache redis

memcache redis


Memcache
Redis
session redis
session session

redis
RDB
dump.rdb redis redis.conf

AOF write() appendonly.aof
Redis redis.conf
appendonly no appendonly yes

append

aof rdb rdb AOF

AOF :
Redis
appendfsync always    # fsync aof
appendfsync everysec  # fsync aof
appendfsync no        # OS


AOF RDB RDB
aof
 

redis-cluster
redis-cluster

redis 6 3 redis 3
PING-PONG redis
Redis-cluster 16384 Redis-cluster
0-16383 slot


Redis redis
redis redis
MULTI EXEC ;

key value value
key value key


1. hash
2. bitmap bitmap

3.





1. key

2. reload
3. key
4. A1 A2 A1 A2 A1
A2

redis redis

redis bind 0.0.0.0:6379 redis
redis
redis redis redis redis


1. redis.conf DB
2. redis redis
3. redis redis.conf requirepass mypassword
4. redis redis.conf bind 127.0.0.1 redis
5. log

redis redis2.6


redis API

master sentinel.conf

redis
Redis expire redis




ActiveMQ

activemq
activemq Activemq

RabbitMQ
RabbitMQ AMQP ActiveMQ JMS JMS Java
JVM java ActiveMQ Java
Map Blob Stream AMQP java
RabbitMQ ActiveMQ

KafKa
Kafka ActiveMQ MQ



MQ
Kafka

Redis
Redis List


, , ,

. ( )
.
, , commit , ,
, ,

: id, ,
, , id





1




session


CAS CAS
web tomcat CAS
ticket CAS CAS

 
ip


1 jQuery jsonp
2 W3C CORS

CAS web.xml cas cas
ticket cookie ticket
ticket cas cas

 

linux awk cat sort cut grep uniq wc top find sed

awk: sed awk awk

cat:
sort:
cut:cut
grep:
uniq:
wc:
top: Linux , cpu
find:
sed:sed





(1)


(2)

(3)

(4)

( MyISAM SQL )
,
,



Java synchronized
for update



write_condition Java
java.util.concurrent.atomic CAS version


, , ,
, , , ,
bug

synchronized
, , , ,
,wait():


synchronized JVM , , ReentrantLock ,
, finally lock.unlock();

synchronized
ReentrantLock



sql

   
Throughput
Latency
Latency Throughput Latency


 

1. SQL join
2.
3. redis DB
4. expire
5.
6.
7.
8. sql
9.
10. :/,NIO
11.IO


1. setex,setnx
set(nx ex) true
setnx(nx ex) false
( 50 )

2
key,
key val

redis set

key
value


1.

2.
while true 200MS




Queue

1.
2.
3. commit()


1
2 commit()
3 CLIENT_ACKNOWLEDGE Session .recover()
4
ActiveMQ.DLQ
ActiveMQ.DLQ
1. Poison ACK the broker
the broker
2. activemq ActiveMQ.DLQ
3. Activemq.xml

Mq 2
1. MessageListener onMessage RuntimeException
2. Message Redelivered false redeliveryCounter 0
3. broker consumer consumer listener
redeliveryCounter++ broker broker message redeliveryCounter++
1s 6 broker broker DLQ
4. 2 consumer broker redeliveryCounter=2 4
DLQ
5. broker broker redelivered
true redeliveryCounter++ broker

 

SOA zookeeper activeMQ

SOA
SOA

activeMQ
1
<systemUsage> ActiveMQ


2 activemq

 
zookeeper



 

JUC

ReentrantReadWriteLock
CountDownLatch
CyclicBarrier
Semaphore

 

SSM

springmvc

1 SpringMVC DispatcherServlet

2 DispatcherServlet URL URI( ) URI HandlerMapping Handler Handler Handler HandlerExecutionChain

3 DispatcherServlet Handler HandlerAdapter HandlerAdapter HandlerAdapter Handler Handler

4 Handler(Controller) Handler spring

json xml

String Integer Double  

BindingResult Error

5 Handler DispatcherServlet ModelAndView ModelAndView

6 ModelAndView ViewResolver( ) DispatcherServlet

7 ViewResolver Model View

8

8 DispatcherServlet HandlerMapping HandlerAdapter ViewResolver SpringMVC > Handler(Controller)

 

springmvc MultipartFile FastDFS

 

SOA

SOA SOA ESB SOA

 

spring AOP AOP

Spring AOP AOP AOP AOP

Spring AOP JDK CGLIB JDK JDK InvocationHandler Proxy Spring AOP CGLIB CGLIB Code Generation Library CGLIB final CGLIB

AOP Spring AOP annotation xml spring @Transactional

 

Spring

MQ MQ

TCC TRYING-CONFIRMING-CANCELING

TRYING

CONFIRMING TRYING TRYING CONFIRMING

CANCELING TRYING TRYING CANCELING

 

Springboot

Springboot

Springboot

a)

Spring XML annotation

Springboot

b)

Xml javaConfig XML bean @bean

application.yml

c)

d)

Spring-boot-start-actuator:

JVM

api

map sdk XML httpClient

www.alipay.com/

SpringBoot

Spring Boot

Spring Boot Spring Spring Spring

Spring Boot

Spring Boot

XML

Spring Boot

Spring Boot application bootstrap

application Spring Boot

bootstrap

Spring Cloud Config bootstrap

/

 

Spring Boot

.properties .yml

 

Spring Boot

@SpringBootApplication Spring Boot 3

@SpringBootConfiguration @Configuration

@EnableAutoConfiguration @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })

@ComponentScan Spring

 

Spring Boot

1 spring-boot-starter-parent

2 spring-boot-dependencies

 

Spring Boot

Tomcat/Jetty .

 

Spring Boot

1

2 Maven/Gradle

3 main

 

Spring Boot

@EnableAutoConfiguration, @Configuration, @ConditionalOnClass

 

Spring Boot Starters

Starters Spring Spring JPA spring-boot-starter-data-jpa

Starters .

 

Spring Boot

ApplicationRunner CommandLineRunner run .

 

Spring Boot

Spring Boot @PropertySource,@Value,@Environment, @ConfigurationProperties

 

activeMq?

ES

 

redis 0 0, redis watch

 

 

redis

redis 5 hash value list set zset hash

 

 

3000 5000

 

? XXX B2B2C/

dubbo ssm es redis activeMQ

 

MySQL Redis Redis Redis MySQL DB

IP IP

 

CAS

CAS

 

token

a token

b URL token

c HTTPS URL

 

      

       

:

redis

 

dubbox+zookeeper

fastdfs

mq

            

 

  tomcat,zookeeper,redis,mysql

Tomcat tomcat

 

redis redis

mq redis CDN Nginx

 

springSecurity shiro

 

Tomcat+nginx

 

      15 32 redis 3 6 fastdfs trackerServer storageServer 6 solr 7 nginx 2 mysql 3 activemq 2

58

 

 

 

 ES

angularJS

angularJS ajax

angularJS angularJS html html

 

Nginx

Nginx ,

angularJS

angularJS springmvc

 

  activeMQ

1

 JMS JMS jdbc

2 Connection start() stop()

 JMS Connection start() stop() jms connection pool connection pool start() stop() jprofiler cpu

3 start()

 Connection start() jms jms

4 Session

Connection Session Connection Connection Session Session Connection Session

5 Session

Session Connection Session Connection Session Session Connection

6

ActiveMQ

 

activeMQ

activeMQ

mq

 

spring jmsTemplate activemq prefetch

jmsTemplate receive() consumer

consumer

activeMQ prefetch

prefetch
consumer MQ MQ message MQ   message prefetchSize 1000 consumer  receive

jmsTemplate jmsTemplate.receive() 1000   jmsTemplae consumer 999 jmsTemplate.receive()  


1 jmsTemplate prefetch 1 activeMQ prefetch   jmsTemplate.receive() consumer  

2 jmsTemplate consumer receive() prefetch consumer MQ

consumer 2 prefetch MQ

 

redis

id,

 

2

1

2

 jpa

 tcc 

 

ip shiro springmvc

 

 

0

 

 

nosql

redis redis watch 0

 

8

1       

2       

3       

 

1       

          a)    

          b)    

          c)    

2       

3       

4       

 

2

 

xxx b2b2c xxx

1 dubbo,zookeeper

            a)    

            b)    

            c)    

2 activeMQ

            a)    

            b)    

3        

4        

5        

6        Nginx

 

 
key id 
 
productId skuId buyNum json cookie skuId skuId productId cookie cookie  
 
long userId,long productId,long skuId,int count productId skuId skuId  
addToCart(long userId,long skuId,int count);//sku

 
 
productId skuId cooike cooike 0  
 
productId skuId userId sku differ  
updateAmount(long userId,skuId,int differ,List selectedSkuIds);//sku differ selectedSkuIds

 
 
productId skuId cookie  
deleteCart(long userId,long skuId, List selectedSkuIds);//sku selectedSkuIds sku sku  
 
productId skuId userId  
4  
 
cookie productId skuId  
 
id  
getCart(long userId,list selectedSkuIds);//selectedSkuIds sku

5.  

6.  

 

1        

.

2        

a)    Centos7

b)    Mysql

c)    Jdk8

d)    Tomcat8

    

2

:

  

   insert max key +1.

  

  : oracle 12

js

  

  jsp js =

   

 

1

a)    

b)     ---

2)   

 

1

2

3

4 0

5

6 5

Tb_seckill_goods 

Tb_seckill_order 

redis 0  

 

mysql 103 8

 

Nginx

 

session

3        Cookie ticket

4        Redis session

session ticket redis

2 session

springsecurity + cas  cas ticket cas ticket

 

1        

2        

3        

 

www.alipay.com

 

redis

1 redis

2 redis

 

solr solr

 

MySQL

   
select * from users where YEAR(adddate)<2007; select * from users where adddate< 2007-01-01 ;
like
like like %aaa% like aaa%
select * from users where name like '%aaa%'
select * from users where name like 'aaa%'

CHAR(255) 10 20 I/O
NULL
NULL , 0 ' '

index( c1 , c2 , c3 ) where c2 = aaa ,where c2 = aaa and c3 = sss where c1 = aaa and c2 = bbb

where c1= xxx and c2 like = aa% and c3= sss ,c3 , like



30%

tu_mdn varchar(20), number where , . select * from test where tu_mdn=13333333333; select * from test where tu_mdn='13333333333 ;

IKAnalyzer

 

seo

restful

 

sql

 

redis

redis 1. redis 2. redis redis 3. redis

LRU

Redis Hash CRC16

Redis

 

redis redis redis

redis 1. redis 2. redis redis 3. redis

 

redis

 

redis key

Redis Redis Redis Redis get set eval API Redis Redis Redis API Redis

 

MySQL

a

b varchar char varchar char 20 1 20

c

d null int 0

e

f

 

mysql mysql

a WHERE

b multiple-column

c joins MySql VARCHAR CHAR

d MIN() or MAX() key_col.

 

    a)

b)

logincount

c) where , where IS NULL/IS NOT NULL/like % % where mysql

d where <>

 

a. or ( or )

or or

  b.

     c.like %

d. ,

     e. mysql ,

 

8 java

        a (100W ) ( quartz)

b  

c

 

Redis

setnx expire value UUID

UUID delete

 

Redis

this.redisTemplate.expire("max",tempTime,TimeUnit.SECONDS);

Redis RDB

 

Redis

RDB 15 5 1

AOF

redis redis redis

RDB redis redis redis

 

redis redis redis

Redis SpringDataRedis .

  Redis string hash list set zset(sorted set )

 

           

Throughput 

Latency  

Latency Throughput Latency

   

       

 

mysql mysql

READ UNCIMMITTED

READ COMMITTED

REPEATABLE READ

SERIALIZABLE

mysql 'REPEATABLE-READ',

 

sql

1 where != <>

2 where order by

3 where null

4 where or

5 in not in

6 where

7 where

8 where =

9

10 select insert update insert update

11 varchar/nvarchar char/nchar

12 select * from t *

 

mysql like

1.WHERE WHERE column!= MYSQL

2. WHERE WHERE DAY(column)= MYSQL

3. JOIN MYSQL

4. WHERE LIKE REGEXP MYSQL LIKE 'abc%',MYSQL LIKE '%abc' MYSQL

5. ORDER BY MYSQL ORDER BY

6. 0/1 Y/N

7. WHERE ORDER BY

8. or( or ) ( or ) or or

9. ,

10. mysql ,

 

Like

mycat

8

 

mysql

  Mycat 500

 

MySql EXPLAIN SQL "EXPLAIN" mysql explain

 

MySQL MyISAM MEMORY table-level locking InnoDB row-level locking

MySQL :
( MyISAM SQL ) ,
,

 

version

for update

 

Mysql

MySQL The MySQL Benchmark Suite MySQL super-smack MyBench MySQL

 

MySQL

a

b varchar char varchar char 20 1 20

c

d null int 0

e

f

 

mysql mysql

a WHERE

b multiple-column

c joins MySql VARCHAR CHAR

d MIN() or MAX() key_col.

 

    a)

b)

logincount

c) where , where IS NULL/IS NOT NULL/like % % where mysql

d where <>

 

a. or ( or )

or or

  b.

     c.like %

d. ,

     e. mysql ,

 

8 java

        a (100W ) ( quartz)

b  

c

 

       a,

        NOTNULL

       b, JOIN (Sub-Queries)

       c, (UNION)

       d,

           a) BEGIN COMMIT SQL ROLLBACK BEGIN

           b) 

       e,

        f,

             

        g,

        h,

 

  1

  2 SQL

  3

  4

   1

   2

  3

 

 

 

.

 

 

session

CAS web.xml cas cas ticket cookie ticket ticket cas cas

 

redis redis3.0

solr solrCloud zookeeper solrCloud

zookeeper

Nginx

 

dubbo zookeeper

Dubbo zookeeper dubbo

 

angularjs controller service json

 

Dubbo Zookeeper Redis

ZooKeeper ZooKeeper

ZooKeeper Web

ZooKeeper

ZK/dubbo/${serviceName}/providers URL Mast

 

Zookeeper

zk

 

dubbo ?

 

dubbo ?

 

ActiveMq

Queue

commit()

ActiveMQ.DLQ

 

activeMQ

A

     ActiveMQ

<persistenceAdapter>

<kahaDB directory="${activemq.base}/data/kahadb"/>

</persistenceAdapter>

producer.Send(request, MsgDeliveryMode.Persistent, level, TimeSpan.MinValue);

      B MySql

      jar activemq

 

activeMQ

       

ActiveMQ Client

 1 Client transactions session rollback()

 2 Client transactions commit()

 3 Client CLIENT_ACKNOWLEDGE session recover()

   

 

Zookeeper

    ip

 

activeMQ

1 <systemUsage> ActiveMQ

2 activemq

 

zookeeper

  

       

 

Dubbo 3

1

2

 

 

mq

Mq 2

1.    MessageListener onMessage RuntimeException

2. Message Redelivered false redeliveryCounter 0

3.  broker consumer consumer listener redeliveryCounter++ broker broker message redeliveryCounter++ 1s 6 broker broker DLQ

4.  2 consumer broker redeliveryCounter=2 4 DLQ

5.  broker broker redelivered true redeliveryCounter++ broker

 

1       

a)    

b)    

c)    

d)    

e)    

f)     Sql

g)    

h)    

2       

a)    

b)    

c)    

d)     ActiveMQ

e)    

3       

a)    Nginx

b)    Lvs

 

        10000+

 

2

1     

2     

3000---5000

4       

a)    

b)    

c)    

d)    

e)    

f)     Sql

g)    

h)    

5       

a)    

b)    

c)    

d)     ActiveMQ

e)    

6       

a)    Nginx

b)    Lvs

 

redis

 

 

Dubbo

Dubbo hessain2

Dubbo netty NIO

 

 

CAS CAS web tomcat CAS ticket CAS CAS

 

ip 1 jQuery jsonp 2 W3C CORS

 

shiro

shiro shiro

 

application Code subject login securityManager realm Realm realm securityManager

 

ES

ES

 

1.

2. redis memcached tair

3. zookeeper

 

ES IK

IK smart smart


smart
| | |
smart
| | | | | | |
smart smart IK

smart

 

java

(PC)

Java

New Thread t = new MyThread();
Runnable start() t.start(); CPU t.start()
Running CPU
Blocked CPU CPU
1. wait()
2. -- synchronized ( )
3. -- sleep() join() I/O sleep() join() I/O
Dead run()

 

Java
1. Thread run()

2. Runnable run()

run() Runnable Thread target Thread Thread

3. Callable Future

Callable clall() FutureTask Callable FutureTask Thread target

,

 

 

   java

5

1.  2.    3. (volatile)  4.  5.  

 

hashmap

Map

(1) for each map.entrySet()

(2) map.entrySet()

(3) for each map.keySet() get

(4) for each map.entrySet() map.entrySet()

 

Es

( ).

 

java

    Lock(ReentrantLock ReadWriteLock ) semaphores BlockingQueue Executor ConcurrentHashMap Fork/Join  

AQS AbstractQueuedSynchronizer (AtomicInteger )

 

jvm

     a,

     b,

     c,

        JVM

 

jvm

      JVM

 

ThreadLocal

ThreadLocal ThreadLocal

ThreadLocal

ThreadLocal ThreadLocal

 

session

session

1        Cookie ticket

2        Redis session

session ticket redis

2 session

 

springsecurity + cas  cas ticket cas ticket

 

1         servlet Tomcat ;

a)   

b)   NIO

2         mybatis 

 

 

activeMq

ES

redis , redis watch

MySQL Redis Redis Redis MySQL DB IP IP

CAS

CAS

CAS?

, CAS Server CAS Client CAS Server

token

a token
b URL token

c.HTTPS URL

      

 

 

: Mycat

redis

es solr

dubbox+zookeeper SOA

fastdfs

mq

tomcat,zookeeper,redis,mysql

Tomcat tomcat

redis redis

mq redis CDN Nginx

springSecurity

shiro

Tomcat+nginx

ES

angularJS

angularJS ajax

angularJS angularJS html html

activeMQ

1 JMS JMS jdbc

2 Connection start() stop() JMS Connection start() stop() jms connection pool connection pool start() stop() jprofiler cpu

3 start() Connection start() jms jms

4 Session Connection Session Connection Connection Session Session Connection Session

5 Session Session Connection Session Connection Session Session Connection

6 ActiveMQ

activeMQ activeMQ

mq

spring jmsTemplate activemq prefetch

jmsTemplate receive() consumer

consumer

activeMQ prefetch

prefetch
consumer MQ MQ message MQ   message prefetchSize 1000 consumer  receive

jmsTemplate jmsTemplate.receive() 1000   jmsTemplae consumer 999 jmsTemplate.receive()  

1 jmsTemplate prefetch 1 activeMQ prefetch   jmsTemplate.receive() consumer  

2 jmsTemplate consumer receive() prefetch consumer MQ

consumer 2 prefetch MQ

redis

id,

2

1

2

 jpa

 tcc 

angularJS

MVC

Model: , angular ($scope.XX);

View:  ,Html+Directive( );

Controller: , function, ;

html css js get post

jq DOM angualr react vue , M(model VM model-view V view

Input V M VM V

Jquery jq dom angularJS

1)   ng( ) ngRoute( ) ngAnimate

2)      angular.module(' ',[ ])

 

nosql redis redis watch 0

1       

a)    

b)    

c)    

2       

3       

4       

2

1 dubbo,zookeeper

a)    

b)    

c)    

2 activeMQ

a)    

b)    

3  

4  

5  

6   Nginx

1

2

3

4 0 redis 0

5

6 5

session

Cookie ticket

 Redis session

session ticket redis

2 session Shiro+ cas  cas ticket cas ticket

 

SpringBoot mybatis springBoot SSM zookeeper dubbo RPC Dubbo Nginx Nginx SpringBoot Thymeleaf easyUI sku spu spu Mate20 sku Mate20 128G Nginx Redis cpu io io Redis Redis Redis Redis Redis Redis Redis redis RDB AOF Redis Redis cookie cookie token token token token IP id map token cookie token token JWT token cookie token cookie tradecode id key value Redis tradecode Redis id tradecode

  

 

 

Spring 

Spring IOC AOP IOC Inversion of Control AOP Aspect-OrientedProgramming

IOC IOC DI Dependency Injection IOC IOC Spring spring

AOP

JDBC

JDBC Java DataBase Connectivity,java SQL Java API Java JDBC

JDBC SQL JDBC API Sybase Oracle Informix JDBC API SQL

Ajax

 

 

 

 

 

IO

(js)

CDN

 

IP

( )

uid UserID uid

100W 100 100W

100 100W

12306

Redis Redis Redis

Redis Redis

Redis key-value (AtomicInteger) key id value RPUSH key value

 LPOP key id

Redis ActiveMQ RabbitMQ

Single Sign On SSO SSO

ticket ticket ticket ticket 2 3

SSO


SSO ticket ticket

ticket
SSO ticket

ticket ticket

token ticket token

Redis mysql

redis *.rdb

redis AOF

redis mysql

redis redis redis

Zookeeper dubbo

1.   Zookeeper

        zookeeper ip zookeeper ip zookeeper

2.  dubbo

       dubbo

       dubbo zk zk

3. zookeeper dubbo

      Dubbo ZooKeeper Memcached Redis

       ZooKeeper ZooKeeper ZooKeeper Web ZooKeeper ZK/dubbo/${serviceName}/providers URL Mast

MQ

Servlet preFilter( ),routeFilter( ) postFilter( ) request response

(1) request,response threadlocal

(2)

(3) threadlocal

Redis mysql redis mysql

  redis redis

redis

Hashmap

HashMap put rehash hash put hash get HashMap

 java.util.Hashtable

 java.util.concurrent.ConcurrentHashMap

 java.util.Collections.synchronizedMap() HashMap object Map Map

Spring cloud

Eureka Eureka Client Eureka Server Eureka Server

Zuul

Dubbo+zookeeper

Dubbo Alibaba Dubbo Provider Consumer

ZooKeeper Apache // ZooKeeper Hadoop HBase Kafka Dubbo

Nginx HTTP IMAP POP3 SMTP Nginx HTTP Nginx

1  
JdbcTemplate 
2  
spring Proxy aop  
3  
 
spring Observer listener ApplicationListener  
4 Adapter  
MethodBeforeAdviceAdapter  
5  
java  
1  
2 excel,pdf,word  
 
6  
 
7  
 

 
1 2

 
A.class  
A B C  
POP3 IMAP,HTTP,

MQ

transaction (channel.txSelect()) (channel.txRollback()) (channel.txCommit())

ID( 1 ) rabbitMQ Ack ( ID) . rabiitMQ Nack

2PC

.NET TransactionScop API WCF DTC

  100%

  .NET

TCC

TCC

Try

Confirm Try Confirm Confirm Try Confirm

Cancel

  2PC 2PC

  2,3 TCC TCC

MQ

MQ

MQ RocketMQ MQ RabbitMQ Kafka

RocketMQ

Prepared

RocketMQ Prepared check RocketMQ

Spring bean GC

spring Bean Bean Bean Spring 5

singleton Spring IoC singleton Bean

prototype getBean prototype Bean Bean

request HTTP request Bean HTTP Bean Web Spring

session HTTP Session session Bean Web Spring

globalsession HTTP Session session Bean portlet context Web Spring

singleton prototype singleton Bean Bean Bean Bean Bean prototype id Bean Spring Bean Spring new Bean Bean

Bean Spring singleton Java Java prototype Bean singleton Bean Bean prototype

spring map bean map GC

Redis MySQL

Redis mysql mysql redis mysql redis mysql redis redis redis mysql redis

Spring aop

Stop

Spring bean

bean xml bean ClassPathXmlApplicationContext ApplicationContext ClassPathXmlApplicationContext

getBean()  getBean() doGetBean() 

getSingleton   bean

 bean   getSingleton(String beanName, ObjectFactory<?> singletonFactory) 

createBeanInstance

populateBean

initializeBean

createBeanInstance   Bean 

populateBean   Bean 

initializeBean 

InnoDB myisam

MyISAM: , ISAM ,ISAM Indexed Sequential Access Method ( ) , . ,MyISAM . MyISAM , . , SELECT MyISAM

InnoDB: . BDB , .InnoDB . BDB , , . INSERT UPDATE, InnoDB

1 token  

2  

3

4

Mysql

Mysql

Aop jdk cglig

CurrentHashmap Synchronized writeeverywhere

sql

Sql

    1

    2

      select ...for update select * from account where name= Max  for update   sql account name= Max

    1

    2 Version

      version version version

: , , , , .

: , , , ( ), ,

Jdk1.7 1.8

MySQL

SQL Stored Procedure SQL

SQL

(1). SQL

(2). SQL

(3). Transaction-SQL Transaction-SQL

(4). Transaction-SQL

(5).

MySQL

CREATE PROCEDURE   ([[IN|OUT|INOUT] [,[IN|OUT|INOUT] ]]) [ ...]

DELIMITER//
CREATE PROCEDURE myproc(OUT s int)
BEGIN
SELECT COUNT(*) INTO s FROM students;
END
//
DELIMITER ;

MySQL ";" SQL DELIMITER//"//" DELIMITER ;

"," MySQL ,IN,OUT,INOUT:

 IN

 OUT:

 INOUT:

BEGIN END

Spring boot spring cloud

Spring boot Spring spring boot Spring Boot Spring Spring Spring

Spring Cloud Spring Boot

Spring Cloud Spring Boot Spring boot Spring Cloud spring boot Spring Cloud Spring boot

zookeeper redis

CREATE TABLE `methodLock` (

`id` int(11) NOT NULL AUTO_INCREMENT COMMENT ' ',  

`method_name` varchar(64) NOT NULL DEFAULT '' COMMENT ' ',

`desc` varchar(1024) NOT NULL DEFAULT ' ',  

`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' ',  

PRIMARY KEY (`id`),  

UNIQUE KEY `uidx_method_name` (`method_name `) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=' ';

SQL  
insert into methodLock(method_name,desc) values ( method_name , desc ) 
method_name

Sql: 
delete from methodLock where method_name ='method_name'

insert

while insert

MySql InnoDB

public boolean lock(){    

    connection.setAutoCommit(false);

    while(true){        

        try{            

            result = select * from methodLock where method_name=xxx for update;            

            if(result==null){                

                return true;           

            }        

        }catch(Exception e){

 

        }

        sleep(1000);

    }

    return false;

}

for update

public void unlock(){ connection.commit(); }

connection.commit();

for update

Redis memcached Redis

Redis Jedis.setNX

public boolean trylock(String key) {    

    ResultCode code = jedis.setNX(key, "This is a Lock.");    

    if (ResultCode.SUCCESS.equals(code))        

        return true;    

    else        

        return false;

}

public boolean unlock(String key){

    ldbTairManager.invalid(NAMESPACE, key);

}

1

2 redis

3

4 key redis setNX

5 setNX

redis setExpire

while

redis A setNX B setNX

redis Salvatore Sanfilippo Redlock DLM

Redlock N redis N=5 N

1

2 N N key value 10s 5-50ms redis

3 3

4

5  
Redlock 2 redis

How to do distributed locking Redlock

Redlock

GC Full GC GC Full GC HBase HBase GC Full GC GC 1 Full GC 2 2 1 Full GC 2

token token version token 1 token token

Zookeeper

zookeeper

zookeeper

Zookeeper

Zookeeper ZK Session

Zookeeper ZK Zookeeper

Zookeeper

Zookeeper ZK

Zookeeper ZK ZK

Zookeeper Redis

Zookeeper

Zookeeper Quorum Based Protocol Zookeeper N Zookeeper (N 3 5 ) N/2 + 1 Quorum Based Protocol Zookeeper

Zookeeper N/2+1 N/2 Zookeeper

Zookeeper

A Zookeeper/z

A B A/z

B Zookeeper/z

B Zookeeper A B A

B Zookeeper/z

A Zookeeper/z Zookeeper/z Leader B

B B

Leader B Leader

Zookeeper Zookeeper

Zookeeper Zookeeper Zookeeper

zookeeper

Dubbo ES

Spring boot dubbo

Ik

Spring

ThreadLocal

ThreadLocal

Hibernate ThreadLocal getSession ThreadLocal session session session ThreadLocal

ThreadLocal session

ThreadLocal ThreadLocal threadSession Thread Thread ThreadLocalMap threadLocals map map ThreadLocal

session

Dubbo

Failover Cluster

1. ( )

2.

3. retries= 2 ( )

 

Failfast Cluster

Failsafe Cluster

.Failback Cluster

Forking Cluster

 

forks= 2

Broadcast Cluster

(2.1.0 )

Redis watch

redis watch multi redis watch+multi

watch

WATCH EXEC EXEC MULTI WATCH

 

 

 

SpringMVC Springboot Mybatis Dubbo Zookeeper Redis Elasticsearch Nginx Fastdfs ActiveMQ

SpringMVC:

Spring Mvc

1 SpringMVC DispatcherServlet

2 DispatcherServlet URL URI( ) URI HandlerMapping Handler Handler Handler HandlerExecutionChain

3 DispatcherServlet Handler HandlerAdapter HandlerAdapter HandlerAdapter Handler Handler

4 Handler(Controller) Handler spring json xml String Integer Double BindingResult Error

5 Handler DispatcherServlet ModelAndView ModelAndView

6 ModelAndView ViewResolver( ) DispatcherServlet

7 ViewResolver Model View

8

url uri

URI URL URN URN URL URN URL

 

Springboot:

Springboot

Springboot spring properties yml  
spring main  
Springboot Tomcat war  
maven

starters

Mybatis:

1 mybatis

1 mybatis java jdbc sql statement

2 mybatis xml statement java statement sql sql mybatis sql java

3 MyBatis SQL MyBatis JDBC MyBatis XML Java POJO

2 Mybait

1 Hibernate - SQL

2 JDBC 50% JDBC

3 MyBatis JDBC JDBC MyBatis JDBC Java jar MyBatis

4 /

5 Spring

6 MyBatis SQL XML sql

7 XML SQL

8 ORM

9

3 MyBatis

1 SQL SQL

2 SQL

4 MyBatis

1 MyBatis SQL DAO

2 MyBatis

5 #{} ${}

#{} ${}

Mybatis #{} sql #{} ? PreparedStatement set

Mybatis ${} ${}

#{} SQL

Dubbo:

Dubbo (Dubbo )

dubbo

Dubbo RPC

RPC

RPC

dubbo

/Container Provider Registry Consumer Monitor

Dubbo

Dubbo NIO

Zookeeper:

Zookeeper

Zookeeper znode znode node getChildren getData,exists znode tree watch watch create delete update client client Zookeeper node

zookeeper dubbo

Zookeeper Znode zookeeper zookeeper zookeeper zookeeper dubbo redis Simple dubbo

zookeeper

zookeeper spring dubbo

Redis:

redis

redis key-value redis redis redis Redis Value 5 string hash list set zset sorted set ;

String key value

Hash key string value map key-value

List LPUSH RPUSH

Set value null hashmap

zset set double score

redis memcache

Memcache redis

redis k/v list set zset hash memcache k/v key value string

memcache redis

memcache redis

Memcache

Redis

session redis session session

redis

redis

RDB dump.rdb redis redis.conf

RDB

Redis dump dump.rdb Redis dump 6379.conf save

save 900 1              # 900 (15 ) 1 key dump

save 300 10            # 300 (5 ) 10 key dump

save 60 10000        # 60 (1 ) 10000 key dump

AOF write() appendonly.aof Redis redis.conf appendonly no appendonly yes

append

aof rdb rdb AOF

AOF :

Redis

appendfsync always     # fsync aof

appendfsync everysec  # fsync aof

appendfsync no          # OS

AOF RDB RDB

aof

 

redis

Redis hadoop Hbase MogoDB redis redis

Redis Twemproxy Codis redis3.0 redis-cluster redis-cluster

redis 6 3 redis 3 PING-PONG redis Redis-cluster 16384 Redis-cluster 0-16383 slot

redis

Redis redis redis redis MULTI EXEC ;

key value value key value key

1. hash

2. bitmap bitmap

3.

1. key
2. reload
3. key
4. A1 A2 A1 A2 A1 A2

redis redis

redis bind 0.0.0.0:6379 redis redis redis redis redis redis

redis.conf DB rename-command FLUSHALL "" rename-command CONFIG"" rename-command EVAL

redis redis

redis redis.conf requirepass mypassword

redis redis.conf bind 127.0.0.1 redis

log

redis redis2.6

redis API

master sentinel.conf

redis

  Redis expire redis

  

Elasticsearch:

Elasticsearch

ElasticSearch Lucene HTTP JSON

lucene elasticsearch solr

lucene lucene jdk tomcat elasticsearch solr, lucene

cluster elasticsearch
node node
shard hash 5
index rdbms database, shard node
type rdbms table table class , Json
document rdbms row object
field

MySQL

kibana elasticsearch restful api (DSL)

Kibana Elasticsearch Kibana Elasticsearch

ES JSON query DSL

es

public class  Movie { String id;     String name;     Double doubanScore;     List<Actor> actorList;} public class Actor{String id;String name;}

2 elasticsearch json document

es

{   id : 1 ,   name : operation red sea ,   doubanScore : 8.5 ,   actorList :[  { id : 1 , name : zhangyi },{ id : 2 , name : haiqing },{ id : 3 , name : zhanghanyu }]}

es java

TransportClient ES dsl Java api

Rest Api missing client jest dsl json

elasticsearch 7.0 TransportClient RestClient RestClient Jest springboot

elasticsearch

1 es es es es io

2 es

redis redis redis

 redis 100 100 es 100

MQ RabbitMQ

MQ MQ MQ ES

Nginx:

1 Nginx?

nginx web HTTP HTTPS SMTP POP3 IMAP

2 Nginx

1/L7

2 Perl

3

4 URL PCRE

3 nginx apache

1 web apache

2 nginx apache nginx

3

4 apache nginx

4.nginx

request worker request worker worker request web server request server @skoo webserver io

5 Nginx HTTP

Nginx

6 Nginx ?

Server {listen 80; server_name ;return 444;} Nginx 444 7 ? web web

8 Nginx ?

Nginx HTTP SCGI WSGI FastCGI

9 Nginx Master Worker ?

Master Worker

10 80 Nginx?

Nginx/etc/Nginx/sites-enabled/default Like server {listen 81;}

11 Nginx 502 503?

502 = 503 = fastcgi_intercept_errors ON Location/{ fastcgi_pass 127.0.01:9001; fastcgi_intercept_errors on; error_page 502 =503/error_page.html; # }

12 Nginx URL ? URL merge_slashes_off; :merge_slashes [on/off] : merge_slashes on : http server

13 ngx_http_upstream_module ?

ngx_http_upstream_module fastcgi proxy uwsgi memcached scgi

14 C10K ?C10K (10,000)

15 stub_status sub_filter ?

1 Stub_status Nginx//   2 Sub_filter

16 Nginx ?

Nginx gunzip gunzip gzip :gzip

17 Nginx ? Nginx SSI $date_gmt $date_local Proxy_set_header THE-TIME $date_gmt;

18 Nginx -s ? Nginx -s

19 Nginx ? Nginx Nginx

20 ?

XX XX XX

nginx nginx DNS NGINX keepalive

Fastdfs:

FastDFS

 

1.

2.FastDFS Tracker server Storage server Tracker server Tracker server Storage server

3.Tracker server Tracker server Storage server

Storage server Storage server Storage server

/

fastdfs

FastDFS

fastDFS   FastDFS

Nginx nginx http location ftp

FastDFS

file_id file_id ip url file_id

FastDFS

ActiveMQ:

activemq

activeMQ

activemq

    activemq  Activemq         

RabbitMQ

RabbitMQ AMQP ActiveMQ JMS JMS Java JVM java ActiveMQ Java Map Blob Stream AMQP java

RabbitMQ Erlang Erlang ActiveMQ

KafKa

Kafka ActiveMQ MQ

 

MQ

  Kafka

Redis

Redis List

, , ,

. ( )

.

, , commit , , ,

,

:

         id, , , , id

session

producer send session.commit()
send
consumer Session.SESSION_TRANSACTED  session.rollback()
Session.AUTO_ACKNOWLEDGE comsumer.receive
Session.CLIENT_ACKNOWLEDGE message.acknowledge(),    ,
Session.DUPS_OK_ACKNOWLEDGE Topic consumer  

producer.setDeliveryMode(DeliveryMode.PERSISTENT)

activemq

 

 

 

:

1

2

soa

SOA

soa

SOA

 

:

tomcat Redis Zookeeper



10 1 10
10 ( Hadoop Map/Reduce
10 10 10 1 10 1

:

1 HTML  freemaker
html CMS CMS

Mop

html html

2  
Web Apache IIS apache ContentType LoadModule

3  

Oracle Sybase MySQL Master/Slave DB

DB ID sohu ID

4  
 
Apache Apache Squid Apache  
Linux Memory Cache web Java MemoryCache web PHP Pear Cache Java .net

5  
ChinaNet EduNet Linux rsync

6  
 
 

:

IOE IBM Oracle EMC PC x86 MySQL Linux

1

2

or

Master Slave Master Slave

 

1

Storm

Load IO

2

>

 

 

:

1.

        

 

1 HTTP

        

        
2 DNS

         DNS

         DNS A
3

       

      
4 IP

      IP

     

5

       

HTTP

         IP HTTP Location 302

Location URL

HTTP HTTP IP  

   

 
IP HTTP Location

(RR) 
IP

IP  

   HTTP

HTTP URL ( )

 

DNS

DNS

DNS DNS

IP IP DNS

IP IP IP

DNS IP DNS IP  

( IP ) DNS

DNS IP IP  

DNS  

DNS DNS DNS

DNS IP

DNS

DNS HTTP

DNS IP DNS DNS  

DNS

DNS DNS DNS

DNS  

 

      

 

 
HTTP

 
DNS

 
HTTP DNS

 

 
 

session Session Session

1  
IP IP

2  
Cookie ID Cookie

 

IP

 

1. NAT

ip ip VIP( IP)

( 8 ) RealServer VIP iptables NAT ip hash

RealServer

ip

1.RealServer ip
2. RealServer
3.RIP
4.RealServer
5. RealServer

NAT

image.png

2.

nat VS/DR RealServer

VIP ip

RealServer ip mac RealServer mac RealServer

RealServer VIP

RealServer

RIP

RealServer

3. VS/TUN

VS/DR RealServer VS/TUN

1. VIP ip ip ip ip ip
2. RealServer ip
3.RealServer VIP VIP IP

RealServer

RIP

RealServer RealSever

RealServer

 

,

500M 1G 1G

linux linux bonding Ether Channel

linux bonding

linux bonding bond

mod=0 (balance-rr) Round-robin policy

1 eth0 eth1 .

mod=1 (active-backup) Active-backup policy -

mac bond MAC switch( ) N 1/N

mod=2 (balance-xor) XOR policy

HASH ( MAC XOR MAC ) % slave xmit_hash_policy

mod=3 broadcast

slave

mod=4 (802.3ad) IEEE 802.3adDynamic link aggregation IEEE 802.3ad

802.3ad slave

slave hash xmit_hash_policy XOR 802.3ad 802.3ad 43.2.4

1 ethtool slave

2 switch( ) IEEE 802.3ad Dynamic link aggregation

3 switch( ) 802.3ad

mod=5 (balance-tlb) Adaptive transmit load balancing

switch( ) bonding slave slave slave slave MAC

ethtool slave

mod=6 (balance-alb) Adaptive load balancing

balance-tlb IPV4 (receive load balance, rlb) switch( ) ARP bonding ARP bond slave

NetScaler F5 Radware Array LVS Nginx HAproxy Linux , NetScaler F5 ~

LVS Nginx HAproxy LVS Nginx HAproxy

LVS Linux Scalability Reliability Manageability

LVS

1 4

2

3

4 IO

5

6 LVS IDC IP Visual IP

Nginx

1 7 http

2 Nginx

3 Nginx

4 1

5 Nginx url

6 Nginx

7 Nginx http Email

8 Session Big request header Round-robin IP-hash

HAProxy

1 HAProxy 7

2 Nginx Session Cookie

3 url

4 (Dynamic Round Robin) (Weighted Source Hash) URL (Weighted Parameter Hash)

5 HAProxy Nginx

6 HAProxy Mysql DB

Nginx HAProxy Nginx HAproxy HTTP

Nginx LVS F5 Nginx LVS F5 LVS F5

LVS LVS F5/LVS< >Haproxy< >Squid/Varnish< >AppServer

Redis

redis

1. redis

2. redis redis

3. redis

redis key

Redis Redis Redis get set eval API Redis Redis Redis API Redis

a

b varchar char varchar char 20 1 20

c

d null int 0

e

f

mysql mysql

1.

2.

3.where != <> null (IS NULL/IS NOT NULL) or in not in/like % %

4.  where = (DAY(column)= )

5. select * from t *

6. select insert update insert update

7. varchar char varchar char 20 1 20

8.

9.

10.

11.

12

13

14 JOIN MYSQL JOIN (Sub-Queries)

java

 a (100W ) ( quartz)

b  

c

Redis

setnx expire (this.redisTemplate.expire("max",tempTime,TimeUnit.SECONDS); ) value UUID

UUID delete

SETEX: key SETEX

SETNX: key SETNX

Redis

RDB 15 5 1

AOF

redis redis redis

RDB redis redis redis

mysql mysql

READ UNCIMMITTED

READ COMMITTED

REPEATABLE READ

SERIALIZABLE

mysql 'REPEATABLE-READ',

mycat

8

MyCat

Mycat 500

MySql EXPLAIN SQL "EXPLAIN" mysql explain

session

CAS web.xml cas cas ticket cookie ticket ticket cas cas

 

Java

    JDK JRE
== equals
hashCode() equals() true
final java
java Math.round(-1.5)
String
java
String str="i" String str=new String( i )

String


final

java IO
BIO NIO AIO
Files

    java
Collection Collections
List Set Map
HashMap Hashtable
HashMap TreeMap
HashMap
HashSet
ArrayList LinkedList
List
ArrayList Vector
Array ArrayList
Queue poll() remove()

Iterator
Iterator
Iterator ListIterator

   



runnable callable

sleep() wait()
notify() notifyAll()
run() start()
44.
45.
submit() execute()
java



ThreadLocal
synchronized
synchronized volatile
synchronized Lock
synchronized ReentrantLock
atomic

   
java

   

Java Web

    jsp servlet
jsp
jsp 4
session cookie
session
cookie session
spring mvc struts
sql
XSS
CSRF

    throw throws
final finally finalize
try-catch-finally
try-catch-finally catch return finally

    http 301 302
forward redirect
tcp udp
tcp
tcp
OSI
get post

JSONP

   

Spring/Spring MVC

    spring
aop
ioc
spring
spring
spring bean
spring bean
spring bean
spring
spring
spring mvc
spring mvc
@RequestMapping
@Autowired

Spring Boot/Spring Cloud

    spring boot
spring boot
spring boot
spring boot
spring boot
jpa hibernate
spring cloud
spring cloud
spring cloud

Hibernate

    hibernate
ORM
hibernate sql
hibernate
hibernate final
hibernate Integer int
hibernate
get() load()
hibernate
hibernate
hibernate getCurrentSession openSession
hibernate

Mybatis

    mybatis #{} ${}
mybatis
RowBounds
mybatis
mybatis
mybatis
mybatis hibernate
mybatis Executor
mybatis
mybatis

RabbitMQ

    rabbitmq
rabbitmq
rabbitmq
rabbitmq vhost
rabbitmq
rabbitmq
141.rabbitmq

rabbitmq
rabbitmq
rabbitmq
rabbitmq
rabbitmq
rabbitmq
rabbitmq
rabbitmq
rabbitmq

Kafka

    kafka zookeeper
kafka
kafka 7 10G 10G kafka
kafka
kafka

Zookeeper

    zookeeper
zookeeper
zookeeper
zookeeper

3 zookeeper
zookeeper

MySql

   
7 2 mysql id

ACID
char varchar
float double
mysql
mysql
mysql

mysql
mysql

mysql
mysql

Redis

    redis
redis
redis memecache
redis

redis
redis java
jedis redisson

redis
189.redis
redis
redis
redis
redis

JVM

    jvm
jvm





java
jvm
jvm
CMS


jvm
jvm